iOS开发技巧(2)
2015-07-23 13:34
417 查看
原文来自:coltfoal's website
一不小心又总结出了第二个列表,就此罗列一下。
[MFMailComposeViewController canSendMail]
发送邮件之前最好先判断是否已经设置好邮箱账号,如果已经设置了,则直接弹窗发送,否则可以生成自己的提示框。如果不使用canSendMail方法判断,而直接判断MFMailComposeViewController是否为空,则系统会自动弹窗提示没有设置邮箱账户。
语言本地化
1.Project-->Info-->Localizations添加Chinese;
2.修改Target-->Info-->Localization native development region设置为China 。
可以让应用的语言变为中文,即包括图片查看器等显示系统语言的地方都能显示为中文。但邮件发送界面无法通过这种方式改变。
阴影导致的滑动卡顿问题
使用UICollectionView显示文件图标等列表时为了美化效果一般会添加阴影,但是添加阴影后滑动明显卡顿,是因为绘制阴影导致的问题。以下是StackOverflow上的解决方案。
http://stackoverflow.com/questions/3677564/drawing-shadow-with-quartz-is-slow-on-iphone-ipad-another-way
总结起来就是三行代码:
在初始化的时候调用这几行代码,滑动速度就提上去了。
自定义AlertView
重写UIAlertController,将自己的视图加进去就可以了。
makeObjectsPerformSelector
使NSArray的每个对象执行某个方法。
可以通过这个方法把某个UIView的SubView全部移出父视图。
UICollectionView滚动停止问题
在边界处向上滑动UICollectionView并长按停止,松开手指发现UICollectionView不会回滚到原来的位置。需要在endDragging的方法里调整UICollectionView的位置。
强制转屏
往系统相册导入视频
一不小心又总结出了第二个列表,就此罗列一下。
[MFMailComposeViewController canSendMail]
发送邮件之前最好先判断是否已经设置好邮箱账号,如果已经设置了,则直接弹窗发送,否则可以生成自己的提示框。如果不使用canSendMail方法判断,而直接判断MFMailComposeViewController是否为空,则系统会自动弹窗提示没有设置邮箱账户。
语言本地化
1.Project-->Info-->Localizations添加Chinese;
2.修改Target-->Info-->Localization native development region设置为China 。
可以让应用的语言变为中文,即包括图片查看器等显示系统语言的地方都能显示为中文。但邮件发送界面无法通过这种方式改变。
阴影导致的滑动卡顿问题
使用UICollectionView显示文件图标等列表时为了美化效果一般会添加阴影,但是添加阴影后滑动明显卡顿,是因为绘制阴影导致的问题。以下是StackOverflow上的解决方案。
http://stackoverflow.com/questions/3677564/drawing-shadow-with-quartz-is-slow-on-iphone-ipad-another-way
总结起来就是三行代码:
self.contentView.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.contentView.bounds].CGPath; self.contentView.layer.shouldRasterize = YES; self.contentView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
在初始化的时候调用这几行代码,滑动速度就提上去了。
自定义AlertView
重写UIAlertController,将自己的视图加进去就可以了。
makeObjectsPerformSelector
使NSArray的每个对象执行某个方法。
可以通过这个方法把某个UIView的SubView全部移出父视图。
UICollectionView滚动停止问题
在边界处向上滑动UICollectionView并长按停止,松开手指发现UICollectionView不会回滚到原来的位置。需要在endDragging的方法里调整UICollectionView的位置。
强制转屏
// arc强制转屏 - (void)forceInterfaceOrientationTo:(UIInterfaceOrientation)interfaceOrientation { UIDevice *device = [UIDevice currentDevice]; SEL sel = NSSelectorFromString([NSString stringWithFormat: @"setOri%@tion:", @"enta"]); if ([device respondsToSelector: sel]) { NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:sel]]; [invocation setSelector:sel]; [invocation setTarget:[UIDevice currentDevice]]; int val = interfaceOrientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } }
// mrc强制转屏 - (void) setInterfaceOrientationForciblyTo: (UIInterfaceOrientation)interfaceOrientation { UIDevice *device = [UIDevice currentDevice]; SEL sel = NSSelectorFromString([NSString stringWithFormat: @"setOri%@tion:", @"enta"]); if ([device respondsToSelector: sel]) [[UIDevice currentDevice] performSelector: sel withObject: (id)interfaceOrientation]; }
往系统相册导入视频
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(videoPath)) { UISaveVideoAtPathToSavedPhotosAlbum(videoPath, nil, nil, nil); }
相关文章推荐
- ios 最全的常用字符串操作
- iOS开发总结——协议代理的认识
- 27个提升效率的iOS开源库推荐
- iOS数据存储
- ios北京总部感想
- iOS 各种动画效果集合
- 【iOS开发系列】简单动画效果
- iOS开发,运行时错误:thread 1: signal sigabrt
- iOS-CAShapelayer
- IOS7 8中tableview分割线缺少15像素
- GitHub上最火的40个iOS开源项目(二)
- GitHub上最火的40个iOS开源项目(一)
- 为什么iOS开发不需要Storyboard?
- IOS第三天
- iOS开发中手势识别
- IOS-内存分区
- iOS 图片设置为圆角矩形,圆形等
- 【iOS学习】四、内存管理相关
- IOS常用宏定义
- iOS多视图控制器跳转方法