0

我正在编写一个基于 Three20 框架的应用程序,我似乎遇到了一些麻烦......

我正在使用 TTTableViewController 从端点加载数据并显示标题列表,单击该列表可以显示一个新的 UIViewController,其中包含一个显示 URL(从 JSON 数据获取)的 UIWebView。但是,当我点击 UIViewController 中的“返回”按钮时,视图会弹回来……但 UIWebView 并没有消失(它是用 [autorelease] 定义的)。它停留在 TTTableView 应该在的位置之上。

我在 SearchResultViewController 中用于初始化 UIWebView 的代码非常简单:

- (void)loadView {
    ....
    // Add the UIWebView
    webView = [[[UIWebView alloc] initWithFrame:CGRectMake(0.f, TT_ROW_HEIGHT + 20, TTApplicationFrame().size.width, TTApplicationFrame().size.height - TT_ROW_HEIGHT - toolbar.frame.size.height)] autorelease];
    // Load the URL
    address = self.productIdentifier;
    NSURL *url = [NSURL URLWithString:address];
    NSLog(@"%@",url);
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];

    [self.navigationController.view addSubview:webView];
    ....
}

SearchResultViewController 的推送也同样简单:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Search Again" style:UIBarButtonItemStylePlain target:self action:@selector(goBack)];
    self.navigationItem.backBarButtonItem = backButton;
    [backButton release];

    SearchResultViewController *srvc = [[SearchResultViewController alloc] init];
    srvc.productIdentifier = [[[(id<SearchResultsModel>)self.model results] objectAtIndex:indexPath.row] url];
    srvc.title              = [[[(id<SearchResultsModel>)self.model results] objectAtIndex:indexPath.row] title]; 
    srvc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:srvc animated: YES];
}
4

1 回答 1

0

弄清楚了; 可笑的愚蠢错误。我将 UIWebView 添加到了整个 navigationController 而不是我需要的视图中。Duh!

于 2010-03-08T00:01:15.273 回答