返回TTTableViewController后隐藏TTTableView

时间:2010-03-07 17:17:07

标签: iphone objective-c uiwebview three20

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

我正在使用TTTableViewController从端点加载数据并显示标题列表,可以单击这些标题列表以显示一个新的UIViewController,其中包含一个显示URL的UIWebView(来自JSON数据)。但是,当我点击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];
}

1 个答案:

答案 0 :(得分:0)

想出来;荒谬的愚蠢错误。我将UIWebView添加到整个navigationController而不是我需要的视图.Duh!