【问题标题】:TTTableView hidden after returning to TTTableViewController返回 TTTableViewController 后隐藏 TTTableView
【发布时间】:2010-03-07 17:17:07
【问题描述】:

我正在编写一个基于 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];
}

【问题讨论】:

    标签: iphone objective-c uiwebview three20


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      相关资源
      最近更新 更多