【问题标题】:iPhone Views QuestioniPhone 浏览量问题
【发布时间】:2010-12-04 18:39:15
【问题描述】:

所以我有一个关于 iPhone 视图的问题。我有一个基于 XCode 中的 Tab Bar 模板的应用程序。选项卡视图之一是 TableView。在该表格视图中,当用户选择其中一个单元格时,我希望它加载一个显示更多详细信息的视图。

现在,我有:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    SportsAppDelegate *appDelegate = (SportsAppDelegate *)[[UIApplication sharedApplication] delegate];


    // Deselect
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];

//Process which one, sets an index

    //Show detail
    SportsGameView *detail = [[SportsGameView alloc] init];
    [detail setMe:index];  //sets the index that tells it which one

    [appDelegate.window insertSubview:detail.view atIndex:0];
    [self.view removeFromSuperview];
    [detail release];
}

在 SportsGameView(我试图在顶部加载的那个)中,我定义了 setMe 来用这些初始化一堆 UILabel。

我可以确认它得到了这些,但不知何故,它实际上并没有出现。我怀疑这与我的.xib 有关。我像往常一样在 SportsGameView 中定义了 IBOutlets,并将它们连接到 Interface Builder 中。

有人知道为什么吗?

对不起,如果这有点混乱。

谢谢!

【问题讨论】:

  • SportsGameView 是 UIView 的子类吗?还是它其实是 UIViewController 的子类?
  • 它是 UIViewController 的一个子类,但是别介意,伙计们,我想通了!我不能把它放到 init 中,因为它实际上还没有做任何事情。
  • 好的,太好了。但是如果你仍然使用 UIViewControllers,你会发现使用 UINavigationController 会更容易,或者至少使用 pushModalViewController 而不是手动进行视图交换。
  • 是的,我想我会这样做。谢谢。

标签: iphone uiview multiple-views


【解决方案1】:

您可能不想使用insertSubview:... atIndex:0 添加视图,这会将其置于所有其他子视图的“下方”。

如果你想把它放在上面,只需使用addSubview:。

【讨论】:

  • 好吧,你现在把它放在everything下面...你应该保持你的视图层次结构整洁并将它添加到正确的superview中。也许中间的导航控制器会很方便。我觉得它是放错位置的窗口的直接子视图。
猜你喜欢
  • 2016-03-09
  • 1970-01-01
  • 1970-01-01
  • 2012-10-15
  • 1970-01-01
  • 1970-01-01
  • 2011-08-14
  • 2020-11-17
  • 2011-03-13
相关资源
最近更新 更多