launching UIWebview with specific url

一笑奈何 提交于 2019-12-21 04:13:16

问题


I currently have a view with four buttons, and would like to be able to launch UIWebview with a specific url for each different button.

I currently am able to launch safari externally with the urls.

I know I can have the code to show the UIWebview within each button, and can set the url withing the viewDidLoad of the UIWebview, but I need a way to load a specific page depending on which button was pressed.

Regards


回答1:


somtheing like this should be called in the IBAction for the buttom click. you can specify a different URL based on the sender

UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)];  
webView.delegate = self;

NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @"www.url.com"] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: myTimeoutValue];  
[self.webView loadRequest: request];  


来源:https://stackoverflow.com/questions/3182769/launching-uiwebview-with-specific-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!