UIWebView无法从其他视图控制器Objective C打开请求的URL

时间:2013-01-25 05:52:05

标签: objective-c url uiwebview controller

mainViewController.h

#import "ECSlidingViewController.h"
-(void)Loadwebview:(NSURL *)url;

mainViewController.m

-(void)Loadwebview:(NSURL *)url
{
   // NSURL *testURL = [NSURL URLWithString:@"http://www.google.com"];
    NSLog(@"loadwebview: %@", url);
    [webViewBox loadRequest:[NSURLRequest requestWithURL:url]];
}

leftViewController.h

#import "mainViewController.h"
#import "ECSlidingViewController.h"

leftViewController.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *urlString = [[dao libraryItemAtIndex:indexPath.row] valueForKey:@"url"];

    NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; //urlString];

    NSLog(@"selected url: %@", url);

    mainViewController *mvc = [[mainViewController alloc]init];
    [mvc Loadwebview:url];  

    //NSLog(@"%@", [[dao libraryItemAtIndex:indexPath.row] valueForKey:@"url"]);

    [self.slidingViewController resetTopView]; //it will show mainViewController 

}

此代码无效... OutPut步骤是, 日志显示:

  

选择的网址:http://www.google.com

     

loadwebview:http://www.google.com

这意味着我将网址从leftViewController.m传递到mainViewController.m并正确调用loadwebview。但问题是webViewBox未打开请求的网址。 : - (

0 个答案:

没有答案