升级到iOS5后ASIHttpRequest库问题及解决方法
来源:互联网 发布:淘宝达人怎么才能直播 编辑:程序博客网 时间:2024/05/17 07:20
升级Xcode后,打开以前创建的工程, 运气好,一个错误都没有,程序也能正常跑起来。由于我程序中用了ASIHttpRequest这个库,让我发现了一个小问题,就是
ASIAuthenticationDialog这个内置对话框在网络有代理的情况下出现,然后无论点cancle或是login都不能dismiss。在4.3的SDK中完全没问题,在5.0的SDK中就会在Console中看到输出:
Unbalanced calls to begin/end appearance transitions for <ASIAutorotatingViewController:>
很明显示在sdk5中, 用这个库有问题,还有在停止调式的时候,程序会有异常产生。
于是很明显示是SDK5的变化影响了ASIHttpRequest的正常使用。于是我要fix这个问题,经过我研究发现,dismiss不起作用是由于UIViewController的parentViewController不再返回正确值了,返回的是nil,而在SDK5中被presentingViewController取代了。于是在ASIAuthenticationDialog.m中找到+(void)dismiss这个方法并修改为:
+ (void)dismiss
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3
UIViewController *theViewController = [sharedDialog presentingViewController];
[theViewController dismissModalViewControllerAnimated:YES];
#else
UIViewController *theViewController = [sharedDialog parentViewController];
[theViewController dismissModalViewControllerAnimated:YES];
#endif
}
还有上面那个Console的错误提示,解决方法是,在ASIAuthenticationDialog.m中找到-(void)show这个方法,并把最后一行代码
[[self presentingController] presentModalViewController:self animated:YES];
修改为:
UIViewController *theController = [self presentingController];
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3
SEL theSelector = NSSelectorFromString(@"presentModalViewController:animated:");
NSInvocation *anInvocation = [NSInvocation invocationWithMethodSignature:[[theController class] instanceMethodSignatureForSelector:theSelector]];
[anInvocation setSelector:theSelector];
[anInvocation setTarget:theController];
BOOL anim = YES;
UIViewController *val = self;
[anInvocation setArgument:&val atIndex:2];
[anInvocation setArgument:&anim atIndex:3];
[anInvocation performSelector:@selector(invoke) withObject:nil afterDelay:1];
#else
[theController presentModalViewController:self animated:YES];
#endif
这下就可以正常运行了哟, 我的问题也解决了。关于ASIHttpRequest的其它方面,到目前为止还没发现问题。
- IOS5:升级到iOS5后ASIHttpRequest库问题及解决方法
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- 个人总结:AS升级到3.0后遇到的问题及解决方法
- iphone升级到ios5后不能激活怎么办?
- iPhone 3GS升级到iOS5后不断重启
- ASIHTTPRequest开源类项目导入问题及解决方法
- ASIHTTPRequest开源类项目导入问题及解决方法
- ASIHTTPRequest开源类项目导入问题及解决方法
- 从vc6升级到vc7的一些问题及解决方法
- 从vc6升级到vc7的一些问题及解决方法
- 从vc6升级到vc7的一些问题及解决方法
- iPhone4升级到ios5教程
- LNMP架构php升级问题及解决方法 php-5.3.10升级到php-5.4.0
- Extjs floating Panel 挡住 提示框或确认框的解决方法
- WPF中Tag绑定的巧用
- js条件注释
- 外国电视节目核心竞争力!
- PPT中如何让文本两端对齐
- 升级到iOS5后ASIHttpRequest库问题及解决方法
- Extjs 双击关闭tab页
- 会话 (session)
- java jni简介
- 關於解決sqlite中加密設計方案缺陷問題
- 获取iOS设备当前ip地址
- 2011.10.23朗讯笔试题
- Jacoco生成java覆盖率报告的两种方式
- 将类成员函数用做C回调函数