URLWithString: returns nil

后端 未结 8 1942
遥遥无期
遥遥无期 2020-12-02 13:12

it may be very easy, but I don\'t seems to find out why is URLWithString: returning nil here.

//localisationName is a arbitrary string here
NSSt         


        
8条回答
  •  误落风尘
    2020-12-02 13:24

    You can use NSURL directly without NSString.

    //.h file

    @interface NewsBrowser : UIViewController {
    
        UIWebView *webView;
        NSURL *NewsUrl;
    
    }
    
    @property (nonatomic, retain) IBOutlet UIWebView *webView;
    
    @property(nonatomic,assign)NSURL *NewsUrl;
    
    @end
    

    //.m file

    [webView loadRequest:[NSURLRequest requestWithURL:NewsUrl]];
    

    And I pass the URL from another view (using NewsUrl variable) to this view.

    Try it.

提交回复
热议问题