使用特定网址启动UIWebview [英] launching UIWebview with specific url
问题描述
我目前有一个带有四个按钮的视图,并且希望能够为每个不同的按钮启动带有特定网址的UIWebview。
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.
我目前能够使用网址在外部发起safari。
I currently am able to launch safari externally with the urls.
我知道我可以让代码在每个按钮中显示UIWebview,并且可以使用UIWebview的viewDidLoad设置url,但是我需要一种方法来加载具体页面取决于按下的按钮。
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.
问候
推荐答案
这样的应该在IBAction中调用对于buttom点击。您可以根据发件人指定不同的URL
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];
这篇关于使用特定网址启动UIWebview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!