Question

Hey guys, I appear to have run into a problem. I have an application (View-based) that has a UITableView displayed on the bottom half of the screen, with the selection of a cell then bringing up a custom cell taking up the bottom of the screen. I have a "more info" button on the bottom right of this cell, and and when it is selected, I wish for it to open a new NIB file, however the only thing I can manage to do is remove the tableView from the screen..I am not sure of what to use before the "addSubview" because it is not self.view which I thought it would be.

- (void)moreInfoButton:(id)selector{
    NSLog(@"Button Pressed");
    MoreInfo *mivc = [[MoreInfo alloc] initWithNibName:@"MoreInfo" bundle:nil];
    [self.tableview removeFromSuperview];
    //[self.view addSubview:(UIView *)mivc];
    [self.navigationController pushViewController:mivc animated:YES];
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"List of Events" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.backBarButtonItem = backButton;
    [backButton release];
    [mivc release];

}

Also, the (UIView *) doesn't do the trick either. Any suggestions?

P.S. The UITableView does not use a navigationController at all, it is just the table, would this be the problem?

Also, what if I chose to just push a new view, and not use the navigationViewController for this view, is this possible?

Was it helpful?

Solution

I can't answer your navigation controller question without seeing more of your program. To answer your other question, without using a navigation controller you can just add a new view with:

newViewVC = [[NewViewVC alloc]initWithNibName:@"NewViewVC" bundle:nil];
[self.view addSubview:newViewVC.view];

Typically newViewVC is declared in your .h so you can release it later.

OTHER TIPS

I have found an easy way: pushing it as a modal.

- (void)moreInfoButton:(id)selector{
    NSLog(@"Button Pressed");
    MoreInfo *mi= [[MoreInfo alloc] initWithNibName:@"MoreInfo" bundle:nil];
    [self presentModalViewController:mi animated:YES];
}

All that is needed is a back button in the new nib file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top