美文网首页
$1:viewcontroller/NSURL ;nil/htt

$1:viewcontroller/NSURL ;nil/htt

作者: 乐乐的熊 | 来源:发表于2018-11-11 22:28 被阅读0次

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文件,添加


image.png

4.

相关文章

网友评论

      本文标题:$1:viewcontroller/NSURL ;nil/htt

      本文链接:https://www.haomeiwen.com/subject/esvtfqtx.html