Reputation: 167
I have navigate to a new class with view by the below table view delegate method but I get a black screen returned.
#import "NewClass.h"
- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName: @"MainStoryboard" bundle: [NSBundle mainBundle]];
NewClass *new = [storyboard instantiateViewControllerWithIdentifier: @"newDetail"];
new.array = localArray;
[self presentViewController: new animated: YES completion: nil];
}
I have NSLog the array on the new class there and the data is received in the new class, all the storyboard name, identifier tag are correct placed, but I don't know why I still getting a black screen, could anyone help me point out what is the error cause there?
Upvotes: 0
Views: 284
Reputation: 2148
try this code:
- (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
NewClass * new = [storyboard instantiateViewControllerWithIdentifier:@"newDetail"];
new.array = localArray;
[self.navigationController pushViewController:new animated:YES];
}
Upvotes: 1
Reputation: 675
It should be,
ViewController *new = [storyboard instantiateViewControllerWithIdentifier: @"newDetail"];
And make sure the id of your view controller is set to newDetail on storyboard
Upvotes: 0