I have a Master-Detail app and I want to load a new view on the click of rows in Master. If I select row-1, the view is different, and on selection of a different row, new view is presented in Detail portion. How can I achieve this thing?
I am doing something like this. The issue is - If I select any of these 2 rows for the first time, the view actually changes. But again when I click on the other row, it does not change.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
TwitterTweetViewController *detailView=(TwitterTweetViewController *)[storyboard instantiateViewControllerWithIdentifier:@"TwitterDetailView"];
self.splitViewController.mainViewController = detailView;
[self.splitViewController.mainViewController viewDidLoad];
[self.splitViewController viewDidLoad];
}
if(indexPath.row == 1)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
TwitterDetailViewController *detailView=(TwitterDetailViewController *)[storyboard instantiateViewControllerWithIdentifier:@"TwitterDetailView"];
self.splitViewController.mainViewController = detailView;
[self.splitViewController.mainViewController viewDidLoad];
[self.splitViewController viewDidLoad];
}
}
What should I do in order to change the view on selecting these rows?