문제

I am working on an IPhone app and i have a UIWebview that by default loads a url.

I need to create a UIToolbar with three buttons under UIWebview which will allow users to hit the buttons and load a new url in UIWebview?

도움이 되었습니까?

해결책

you have to add three buttons to your toolbar( This can be easily done by using the Interface builder(IB) and connect them to there respective IBAction in the IB.

now when tap on a a button you can do like this.

you have a UIWebView say myWebView //declared in .h file and properly linked with the your View using IB.

when you are done with the basic initialization

for button1 press

   -(IBAction)button1:(id)sender
    {
          NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
          NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
          [myWebView loadRequest:requestObj];
    }

so by clicking on the button1 google webpage is loaded in your webView.

do the same for other button also. :)

다른 팁

These methods and properties of UIWebview maybe help:

- (void)reload;
- (void)stopLoading;

- (void)goBack;
- (void)goForward;

@property(nonatomic,readonly,getter=canGoBack) BOOL canGoBack;
@property(nonatomic,readonly,getter=canGoForward) BOOL canGoForward;
@property(nonatomic,readonly,getter=isLoading) BOOL loading;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top