I've been following this tutorial to have a Slide-Out Menu. I've added a TableViewController which will display a list of articles. For some reason the viewDidLoad
is not firing.
In this tutorial a SideViewController
controls which controller will be displayed, in case of having a segue
with identifier "showPhoto", it will load a specific image.
// Set the photo if it navigates to the PhotoView
if ([segue.identifier isEqualToString:@"showPhoto"]) {
PhotoViewController *photoController = (PhotoViewController*)segue.destinationViewController;
NSString *photoFilename = [NSString stringWithFormat:@"%@_photo.jpg", [menuItems objectAtIndex:indexPath.row]];
photoController.photoFilename = photoFilename;
}
I thought of recreating the same thing for the TableViewController
and trying to force the viewDidLoad
of the controller as seen here Force viewDidLoad to fire on iOS but it still didn't work:
if ([segue.identifier isEqualToString:@"showList"]) {
TableViewController *tableController = (TableViewController*)segue.destinationViewController;
[tableController view];
}
TableViewController viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
// Change button color
_sidebarButton.tintColor = [UIColor colorWithWhite:0.1f alpha:0.9f];
// Set the side bar button action. When it's tapped, it'll show up the sidebar.
_sidebarButton.target = self.revealViewController;
_sidebarButton.action = @selector(revealToggle:);
// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
// Set this view controller object as the delegate and data source for the table view
self.listTableView.delegate = self;
self.listTableView.dataSource = self;
// Create array object and assign it to _feedItems variable
_feedItems = [[NSArray alloc] init];
// Create new HomeModel object and assign it to _homeModel variable
_homeModel = [[HomeModel alloc] init];
// Set this view controller object as the delegate for the home model object
_homeModel.delegate = self;
// Call the download items method of the home model object
[_homeModel downloadItems];
}
What's weird is that the other two Controllers being used (PhotoViewController
and MapViewController
) work as expected...maybe there's some settings than I'm missing.
I've literally just started on iOS, can't work this out unfortunately.
Move your code to
hope it will work.
There are multiple issues with
TableViewController
(as per the project archive you shared)TableViewController.h
should be:
TableViewController.m
in
-viewDidLoad
, observe:Storyboard
Select that
UITableViewController
:TableViewController
(via Identity Inspector)Top Bar
toTranslucent Navigation Bar
(via Attributes Inspector)UINavigationItem
UIBarButtonItem
on it and set it to menu (as you've done in the otherviewControllers
)IBOutlet
objectsidebarButton
to thisUIBarButtonItem
SidebarViewController.m
in your
-prepareForSegue:sender:
method, if you aren't passing data toTableViewController
then you need not do anything