1.获取当前viewController
-(UIViewController *)viewController{
UIResponder *next = [self nextResponder];
do {
if ([next isKindOfClass:[UIViewController class]]) {
return (UIViewController*)next;
}
next = [next nextResponder];
} while (next!= nil);
return nil;
}
2.NSURL URLWithString return nil 问题解决
1 已经弃用的方法
// 经过转义的URL
NSString* webStringURL = [routeString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *routeURL = [NSURL URLWithString:webStringURL];
2.iOS9之后的方法
NSString *str1 =[str stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSURL *routeURL = [NSURL URLWithString:str1];
https://www.jianshu.com/p/dbb15f019127
https://www.jianshu.com/p/dbb15f019127
3.iOS 9不能访问HTTP的解决方法(链接、图片链接、视频链接)
在Xcode工程中找到Info.plist文件,添加

网友评论