I'm adding a split ViewController with the table view and detail view:
The tableview works fine the cell are been populated and everything but when one of the cells is been selected I get the error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<masterViewController: 0x15ce0e9b0>) has no segue with identifier 'detailView''
Here is my code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"detailView" sender:[_arrayOfFiles objectAtIndex:indexPath.row]];
}
Here is the info of the detailView:
I add identifier to the storyboard segue:
but now I'm getting the following error:
* Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'show tableVIew'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
* First throw call stack:
You need to set the identifier for the segue, not the viewController. If you click on the line joining the two viewControllers, you can then set the attributes for the segue in the attributes inspector:
If I'm not wrong you should be adding a Navigation Controller to bot the Master and Detail View Controllers.
Additionally, for a split controller to function it must be set as the root controller.
Good luck!
Related
I have a viewControllerA embedded in a navigationController.From this viewControllerA I want to navigate to another viewControllerB which is embedded in a tabBarController.
So I have a setup like -
viewControllerB is embedded in a navigationController and then this is embedded in tabBarController.
In viewControllerA I have a button from where I want to push to viewControllerB.
This is what I am trying to do -
-(void)areaBtnClicked:(id)sender{
NSLog(#"btn clicked");
UITabBarController *tbc = [self.storyboard instantiateViewControllerWithIdentifier:#"tabController"];
[self.navigationController pushViewController:tbc animated:YES];
}
However the app is crashing with a error message as -
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
Are you sured, that your controller has that identifier "tabController" ?
Check your storyboard.
Well apparently deleting the app from simulator solved the problem.
I am trying to push a table view controller that I have on my storyboard from a view controller that I don't have in my storyboard. I get these errors when i get to initializing the first table view cell. I've made sure the table view controller and the table view cell are set to the correct class types that I've defined and I've set the correct identifier for the cell.
Error Occurs at Line:
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ListPrototypeCell" forIndexPath:indexPath];
Error:
*** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:5439
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier ListPrototypeCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
What am I missing?
P.S that other link does not have the answer, I need to initialize multiple cells of this type, I need the index for different data.
Why not just put all the view controllers in one storyboard?
If you're trying to push from a UITableViewCell, you could use a segue method.
First: Control-Drag from your TableViewController to your ViewController to link them with a push segue. Name the segue. E.G. "segueName"
Create a prepareForSegue method like so:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"segueName"])
{
// do whatever you want here
}
and then under your didSelectRowAtIndexPath:, run the segue using this:
[self performSegueWithIdentifier:#"segueName" sender:nil];
Perhaps you could elaborate a bit more, if this does not work.
my code is breaking on the segue. the segue was modal at first , i tried to change it to push but its still not working my code is the following :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if ([[segue identifier ] isEqualToString:#"detailLoanSeg"]){
detailLoan *theController=[segue destinationViewController];
theController.time=_time;
theController.cuurLoan=_cuurLoan;
theController.currName=_currName;
}
}
and the error in xcode is :
014-05-07 04:38:11.257 LoanCalc[1561:a0b] -[UIViewController setTime:]:
unrecognized selector sent to instance 0xa05f1f0
2014-05-07 04:38:11.266 LoanCalc[1561:a0b] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UIViewController setTime:]:
unrecognized selector sent to instance 0xa05f1f0'
It looks like, in storyboard, you forgot to indicate the custom class of the destination view controller. In storyboard, select that destination VC, click the third inspector from the right and set it's Custom Class to "detailLoan" (which violates class naming convention).
The error is that your destination vc is a generic UIViewController, which naturally doesn't implement the setTime: method.
Are you sure the destination class is your View Controller and not a UINavigationController? Put a breakpoint and check what theController class is. Also make sure that the view controller in the Storyboard has its class set from the default UIViewController to your custom subclass. It's almost certainly one of those two issues.
In my storyboard I have 2 views one master and one detail with list. I want to show detail view on master. When I add detail to master like that:
- (void)viewDidLoad
{
[super viewDidLoad];
tableViewController = [[TableViewController alloc] init];
[self addChildViewController:detailVC];
[self.view addSubview:detailVC.view];
}
I get crash like that:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
Im sure that there is everything ok with my table viewController becouse when I set it to rootViewController there is everything ok. What I'm doing wrong?
Looks like its an issue with tableview delegate methods. In story board please use static cell for your table view controller and remove table view delegate methods or else implement all required table view delegate methods.
I have two different storyboards named "MainStoryboard" and "TPStoryboard". In TPStoryboard, I have set CCViewController as my initial view controller (names are changed here).
In MainStoryBoard, I have a tableView, and when user selects a cell, he is expected to land in the initial view controller of TPStoryboard. The following is the code I have written:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIStoryboard *stb = [UIStoryboard storyboardWithName:#"TPStoryboard" bundle:nil];
CCViewController *ccv = [stb instantiateInitialViewController];
[self.navigationController pushViewController:ccv animated:YES];
}
This gives the exception
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'TPStoryboard' in bundle NSBundle"
The error states that there's not such file in the bundle, so it's very likely that you are either misspelling the name or that the storyboard file is not included in the target.