开发者

how to make web browser in Xcode load a web page automatically

开发者 https://www.devze.com 2023-02-17 00:09 出处:网络
I am building a web browser in Xcode cocoa application, using the interface builder. I have it all working when it comes to typing in web address and clicking go.

I am building a web browser in Xcode cocoa application, using the interface builder. I have it all working when it comes to typing in web address and clicking go.

but I would like for it to automatically load a web page instead of seeing white when I open开发者_如何学JAVA my project, I looked in inspector to see if you can set a specific web address but I couldn't find anything to do this.


How about if you load the URL that you would like in the viewdidload function:

    - (void)viewDidLoad {
    [super viewDidLoad];
 NSURL *targetURL = [NSURL fileURLWithPath:WebsitePath];
         NSURLRequest *WebRequest = [NSURLRequest requestWithURL:targetURL];
        [self.WebViewer loadRequest:WebRequest];
        self.WebViewer.scalesPageToFit = YES;
}


Maybe you can try to load the WebView when the application finish launching,just add the URL Request in the applicationDidFinishLauching parameter,else if your WebView is on the MainView you can add a loadingScreen that appear while the webView is loading! Lucky!

0

精彩评论

暂无评论...
验证码 换一张
取 消