【问题标题】:How to insert UITableView in UINavigationController如何在 UINavigationController 中插入 UITableView
【发布时间】:2014-07-28 18:21:09
【问题描述】:

我正在申请一份。 App的主视图是singleViewController。
在我点击 singleViewController 中的标签后,显示转到 UINavigationController 实例屏幕(参考:捕获的图像)。 下面的代码是方法,当我点击标签时。
那么,我想问的是关于

1. 在 UINavigationController 中添加 UITableView 应该怎么做?
2. 我应该准备 UINavigationController 类文件(.h 和 .m)

◆下面是我的过渡图

[singleViewController(不带 UINavigationController)] ←→[UINavigationController(带 UITableView)]

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
if ( touch.view.tag == mainCountryLabel.tag ){
    NSLog(@"%d", mainCountryLabel.tag);
    NSLog(@"Label Clicked !!");
    UINavigationController *testView = [[UINavigationController alloc] init];
    testView.view.backgroundColor = [UIColor redColor];
    [self presentViewController:testView animated:NO completion:nil];
}

最好的问候

【问题讨论】:

  • 你在使用故事板吗?
  • >>YuviGr 我不会用storyboard,因为我想深入了解Objective-c。我觉得storyboard很有用,但对程序员来说没什么价值。

标签: ios iphone objective-c uitableview uinavigationcontroller


【解决方案1】:

您可以做的不是使用默认的UINavigationBar,而是使用自定义的。您可以在控制器的viewWillAppear: 中执行[navController setNavigationBarHidden:YES animated:YES];,并添加一个自定义视图来代替您的导航控制器,并在其中嵌入UITableView。这种方法会更容易,因为您可以相应地自定义您的UINavigationBar

希望这会有所帮助。谢谢。

【讨论】:

  • 非常感谢,我在您的想法中定制了点。但是,我的形象接近临空的想法。无论如何,我可以得到有关它的信息!谢谢!!
  • @tomojiro 嘿,没关系 :) 感谢您的支持 :)
【解决方案2】:

我建议你用UINavigationControllerRootViewController初始化SingleViewController

如果不是,则单击按钮时,您将呈现NavigationContorllerUITableView。 所以禁用你的导航栏是因为这个差距。

只需使用隐藏属性,并将其设置为YES

【讨论】:

  • 你好,临空。我理解你的明智建议。我会试试看。非常感谢!!
猜你喜欢
  • 2011-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多