2012-07-30 57 views
0

更新iOS:Webview不会加载页面,可能的启动问题?

修复了加载问题。当我使用自定义单元类时,我只将storyboard中的tableview单元格的标识符设置为customcell的名称,而不是实际的类本身!菜鸟错误,对不起!

这解决了在viewDidLoad方法中加载网页的问题。现在我只需要对它进行排序,以便根据表格行选择加载正确的网页。 PrepareForSegue理想吗?由于

原贴

在我的应用我有FirstViewController与实现代码如下列出的对象打开时然后加载网页视图中secondviewcontroller。

所以在我的didSelectRowAtIndexPath方法方法我目前有:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ [self performSegueWithIdentifier:@"Detail" sender:self]; 
    NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow]; 
    DetailViewController *detailViewController = [DetailViewController alloc];  
    detailViewController.urlToGet = @"www.google.com" 
} 

当然现在DetailViewController在故事板的视图 - 控制对象,其中委托和webView的出口设置。

在DetailViewController类本身我甚至在viewDidLoad中尝试只是为了得到一些网站显示:

 NSString *fullURL = @"http://www.google.com"; 
NSURL *url = [NSURL URLWithString:fullURL]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[webView loadRequest:requestObj]; 

但我得到的是一个空白的网页流量。

我尝试了一个新的项目,它工作正常,然后复制它的教程 - 遗憾的是它现在不在这里工作。

我也尝试prepareForSegue(因为这将得到的信息),但这没有奏效。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 

    /* 
    When a row is selected, the segue creates the detail view controller as the destination. 
    Set the detail view controller's detail item to the item associated with the selected row. 
    */ 
    if ([[segue identifier] isEqualToString:@"Detail"]) { 

     DetailViewController *detailViewController = [segue destinationViewController]; 
    detailViewController.urlToGet = @"www.google.com"; 
} 

}

对于具有详细的标识符在两个ViewControllers之间的SEGUE。

任何想法,为什么我不能让对象甚至加载其viewDidLoad中指定的网站?

感谢

+0

'''''''''''''''''''''之后'''''''查看控制器? – 2012-07-30 20:43:18

+1

修正了它!将在2天内添加一个合适的答案(当它允许我)时,但因为我使用的是自定义单元类,所以我只将storyboard中的tableview单元格的标识符设置为customcell的名称,而不是实际的类本身!菜鸟错误,对不起! – 2012-07-30 20:43:54

回答

0

修正了它!我正在使用自定义单元类我只在storyboard中将tableview单元格的标识符设置为customcell的名称,而不是实际的类本身!菜鸟错误,对不起!

0

你必须init视图控制器。在那里发生子视图等。