aherlambang
aherlambang

Reputation: 14418

UINavigationController and UITableView issues in modalView

I have the following code:

- (IBAction)showDirectMessage:(id)sender
{
    DetailMessageViewController * dmvc = [[DetailMessageViewController alloc] init];
    dmvc.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentModalViewController:dmvc animated:YES];
}

What I am trying to do here is to present a view which has a NavigationBar on top and a UITableView as the view inside. However as of now it only shows the UITableView. I am confused on what I need to change. In my DetailMessageViewController IB I dragged in a UINavigationController and put in a UITableView inside as a view. However, I hooked up the UINavigationController to the UITableView view's.. I think this is wrong. I don't know how am I supposed to do this. Can someone guide me through?

Upvotes: 0

Views: 601

Answers (2)

Gypsa
Gypsa

Reputation: 11314

DetailMessageViewController *dmvc=[[[DetailMessageViewController alloc]initWithNibName:@"DetailMessageViewController" bundle:nil]autorelease];    
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:dmvc]autorelease];
[navController setModalTransitionStyle:UIModalPresentationFormSheet];
[[self navigationController] presentModalViewController:navController animated:YES];

Upvotes: 0

TopChul
TopChul

Reputation: 439

You should use presenting new NavigationController with your ViewController.

- (IBAction)showDirectMessage:(id)sender
{
    DetailMessageViewController * dmvc = [[DetailMessageViewController alloc] init];
    UINavigationController *naviContoroller = [[UINavigationController alloc] initWithRootViewController:dmvc];
    naviContoroller.modalPresentationStyle = UIModalPresentationFormSheet;

    [self presentModalViewController:naviContoroller animated:YES];

    [naviContoroller release];
    [dmvc release];
}

Upvotes: 3

Related Questions