如何使UIBarButtonItem向UIWebView发送新地址

时间:2010-07-10 07:40:28

标签: iphone uiwebview uibarbuttonitem

我在导航控制器中嵌入了uiwebview。我希望能够通过简单地点击一个uibarbuttonitem来改变uiwebview。有谁知道怎么做?

这是我现在拥有的方法。

-(void)action {

    if (item.link) {
        self.linkString = item.link;
    }
    NSString *urlAddress = @"%@/#comments", linkString;

    NSURL *address = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:address];
    [contentLabel loadRequest:requestObj];
}

1 个答案:

答案 0 :(得分:0)

您可以设置目标选择器或IBAction来更改请求对象:

  -(IBAction) action {
         NSString *urlAddress = @"http://google.com";

         NSURL *address = [NSURL URLWithString:urlAddress];
         NSURLRequest *requestObj = [NSURLRequest requestWithURL:address];
         [theWebView loadRequest:requestObj];
    }

  -(void) action {
         NSString *urlAddress = @"http://google.com";

         NSURL *address = [NSURL URLWithString:urlAddress];
         NSURLRequest *requestObj = [NSURLRequest requestWithURL:address];
         [theWebView loadRequest:requestObj];
    }