I'm new to iOS development and I'm having a big headache not understanding something that may be pretty easy.
Basically I'm using a UITableViewController to go to another UITableViewController, but then I need to go from that second UITableViewController to a UIViewController. I want this UIViewController to have a .xib file for me to make a quick UI but I can't seem to find the way to push from the Second UITableViewController to this UIViewController.
I managed to programatically show a label, but not a UI from a .xib.
This is the code that works with the programmatic label:
- (void)tableView:(UITableView *)tableView
self.detailController.title = @"Disclosure Button Pressed";
NSString *selectedMovie = self.movies[indexPath.row];
NSString *detailMessage = [[NSString alloc]
initWithFormat:@"This is details for %@.",
self.detailController.message = detailMessage;
self.detailController.title = selectedMovie;
- (UILabel *)label;
UILabel *label = [[UILabel alloc] init];
label.numberOfLines = 0;
label.textAlignment = NSTextAlignmentCenter;
self.view = label;
self.label.text = self.message;
Loading up a
UIViewController from a xib is easy. When your tableview delegate sends the
didSelectRowAtIndexPath: message you can load up a xib and present the view controller as follows:
BIDDisclosureDetailViewController *controller = [[BIDDisclosureDetailViewController alloc] initWithNibName:@"BIDDisclosureDetailView" bundle:nil]; [self.navigationController pushViewController:controller animated:YES];
Some things to note:
loadViewcode you have in there as well, it will mess things up when trying to use the xib.
Side note! you should not have semi-colons at the end of method signatures like this one:
It is considered bad form.
Hope this helps!