2

主视图控制器.h

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

主视图控制器.m

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

左视图控制器.h

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

左视图控制器.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 

}

此代码不起作用...输出步骤是,日志显示:

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

加载网络视图:http ://www.google.com

这意味着我正在将 url 传递给leftViewController.mtomainViewController.m并正确调用loadwebview函数。但问题是webViewBox没有打开请求的网址。:-(

4

0 回答 0