您的位置:首页 > 移动开发 > IOS开发

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的。

打开terminal终端,cd图片目录,输入命令sips -s format png *.* --out pngs,再把图片覆盖即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: