iOS 开发小记 (五)
2015-11-06 15:16
246 查看
1、UIAlertController 提示框
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"取消订单" message:@"取消这次订单" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
[[OrderMessage instance] requestCancelUserOrder:order_id];
}];
[alertController addAction:okAction];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
一个是上拉菜单选择;一个是弹出框选择;
UIAlertControllerStyleActionSheet,
UIAlertControllerStyleAlert
2、引用
PhoneCallDelegate
在IOS里面使用代理模式,切记切记,__weak必须加。
__weak UIViewController* controller = self;
[dataSource setSelectCallBack:^(long index, id data) {
UIViewController* dance = controller;
Order* order = (Order *)data;
open_order_id = order.order_id.integerValue;
[controller performSegueWithIdentifier:@"open_order_detail" sender:controller];
}];
在一个block中使用了self时,需要使用weak-strong dance。
如果把block赋值给自己持有的变量,切记把block引用设置为weak。
注意,上面的代码有bug, __weak __typeof(self) controller = self;才是正确的用法。
3、BUG
通过segue打开一个页面,包括UItextView,text里面只有abc三个字母的时候,会卡死,找不到原因。
4、真机调试
引人:
iOS真机调试程序,报如下错误信息:
failed to get the task for process XXX
原因:
证书问题,project和targets的证书都必须是开发证书,ADHOC的证书会出现此问题。
解决方案:
project和targets的证书使用开发证书。
创建尺寸至少为 44 像素 x 44 像素的控件
闭包和 block 都是独立的内存对象,会 retain 它们所引用的对象,因此如果我们有个类,里面有个闭包变量,并且这个闭包恰好引用了自身所属对象的一个属性或方法,那么就可能产生循环引用
5、图片转码 sips
png的图片只是命名为png,格式不是png的。
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"取消订单" message:@"取消这次订单" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
[[OrderMessage instance] requestCancelUserOrder:order_id];
}];
[alertController addAction:okAction];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
一个是上拉菜单选择;一个是弹出框选择;
UIAlertControllerStyleActionSheet,
UIAlertControllerStyleAlert
2、引用
PhoneCallDelegate
在IOS里面使用代理模式,切记切记,__weak必须加。
__weak UIViewController* controller = self;
[dataSource setSelectCallBack:^(long index, id data) {
UIViewController* dance = controller;
Order* order = (Order *)data;
open_order_id = order.order_id.integerValue;
[controller performSegueWithIdentifier:@"open_order_detail" sender:controller];
}];
在一个block中使用了self时,需要使用weak-strong dance。
如果把block赋值给自己持有的变量,切记把block引用设置为weak。
注意,上面的代码有bug, __weak __typeof(self) controller = self;才是正确的用法。
3、BUG
通过segue打开一个页面,包括UItextView,text里面只有abc三个字母的时候,会卡死,找不到原因。
4、真机调试
引人:
iOS真机调试程序,报如下错误信息:
failed to get the task for process XXX
原因:
证书问题,project和targets的证书都必须是开发证书,ADHOC的证书会出现此问题。
解决方案:
project和targets的证书使用开发证书。
创建尺寸至少为 44 像素 x 44 像素的控件
闭包和 block 都是独立的内存对象,会 retain 它们所引用的对象,因此如果我们有个类,里面有个闭包变量,并且这个闭包恰好引用了自身所属对象的一个属性或方法,那么就可能产生循环引用
5、图片转码 sips
png的图片只是命名为png,格式不是png的。
打开terminal终端,cd图片目录,输入命令sips -s format png *.* --out pngs,再把图片覆盖即可
相关文章推荐
- iOS 隐藏顶部状态栏
- 招聘一个靠谱的 iOS
- 苹果开发的一些要求(汇总到这里)
- iOS 开发博客汇总
- ios原生二维码扫描
- MWPhotoBrowser, simple and elegant image library for iOS
- 2015/11/6 IOS9适配
- iOS KVC & KVO
- dSYM文件分析
- ios socket通信
- iOS NSDate 各种时间字符说明
- iOS 处理图片的一些小 Tip
- ios 开发日记 21 -自动处理键盘事件的第三方库:IQKeyboardManager
- 多线程
- IOS 给Label添加下划线,删除线,不同的颜色和大小
- iOS 开发 高级:使用 宏定义macros (#,##,...,__VA_ARGS_)
- <iOS>GCD使用经验与技巧
- iOS 获取手机的型号,系统版本,软件名称,软件版本
- iOS_静态库合并
- iOS_二维码扫描(iOS自带)