Yaemon
Yaemon

Reputation: 81

How to insert UITableView in UINavigationController

enter image description here

I'm making one application. The App's main view is singleViewController.
After I tap the Label in the singleViewController, the display goes to UINavigationController instance screen (Reference:Captured Image). Below code is the method, when I tap the label.
Then, what I want to ask is about

1. what should I do to add UITableView in the UINavigationController ?
2. And should I prepare for UINavigationController class file(.h and .m)

◆My transition image is below

[singleViewController(without UINavigationController)] ←→ [UINavigationController(with 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];
}

Best Regards

Upvotes: 2

Views: 663

Answers (2)

Rinku Sadhwani
Rinku Sadhwani

Reputation: 86

I will suggest you to initialise SingleViewController with UINavigationController's RootViewController.

If not, then on button click you are presenting NavigationContorller with UITableView. So disable your navigation bar this gap is because of that.

Just use a hidden property, and set it to YES.

Upvotes: 1

try catch finally
try catch finally

Reputation: 881

What you can do is instead of using the default UINavigationBar you can use a customized one. You can do [navController setNavigationBarHidden:YES animated:YES]; in the viewWillAppear: of your controller and add a customized view in place of your navigation controller with the UITableView embedded in it. This approach will be easier because you have the freedom of customizing your UINavigationBar accordingly.

Hope this helps. Thanks.

Upvotes: 2

Related Questions