App crashes when moving from UITableView to second view - iphone

i have a UITableView and a second web view that i wish to move to when a cell is touched.
my problem is the program is crashing with
'NSInvalidArgumentException', reason: 'Receiver (<ViewController: 0x1e583890>) has no segue with identifier 'testing''
*** First throw call stack:
(0x326342a3 0x3a35197f 0x34647e31 0x78633 0x344fe28d 0x34580f81 0x32f42277 0x326095df 0x32609291 0x32607f01 0x3257aebd 0x3257ad49 0x361512eb 0x34490301 0x7724f 0x3a788b20)
libc++abi.dylib: terminate called throwing an exception
i have looked at every solution posted on here, tutorials and still cant see what is wrong.
I am new to story boards and iOS
here is some pieces of my code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"testing" sender:self];
}
yes i do have a segue called "testing"
i tried commenting out [self performSegueWithIdentifier:#"testing" sender:self];
and using
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"testing"]){
NSLog(#"identifier is equal");
webviewViewController *ViewController =segue.destinationViewController;
}
but when the cells were pressed then nothing happened, and #"identifier is equal" didnt show up in the log.
hope this helps

its telling that you not have the segue named "testing" . be sure of it,if you have mentioned segue, check for spelling.
else if you are not mentioned segue,plz mention it by clicking segue & writing name for it in inspector window

I've had this error before, and in fact this answer right here helped me out.
I had renamed my Storyboard and forgot to change it in the other necessary places. Make sure all of your information matches up correctly and that you're using the right version of your Storyboard.
Once you're done, make sure to uninstall the app on your simulator or device and retry.

ok i have found the problem, I had added a navigationcontroller to the ViewController in the app delgate file didfinishlaunchingithoptions, i had forgotten about this.
I have removed it and naturally it all works
thanks alot for all the answers

Related

View Navigation Issue - 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle

I'm new to programming in objective C so I have a feeling this is just something really stupid I'm doing or failing to do...
I have an iPhone app and am trying to navigate from one view to another. I hooked up a segue and when I call it, like this:
[self performSegueWithIdentifier:#"ShowPolicyInformation" sender:sender];
it works just fine. But now I want to pass a value to my new view, and from what I can tell I can't do that with a segue. So I setup some properties on it and am trying to navigate to it more manually:
PolicyInfoViewController *pol =[[PolicyInfoViewController alloc] initWithNibName:#"PolicyViewController" bundle:nil];
pol.PropertyOne=txtOne.text;
pol.strPropertyTwo=txtTwo.text;
[[self navigationController] pushViewController:pol animated:YES];
When I replace the performSeque code with the code above, it builds fine, but I get this error when I run it:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'MainMobileViewController''
When I search for help with this issue, all of the suggests that are shown talk about making sure the .xib file is named correctly....and here is where I'm completely lost, because I don't have any .xib files that I can see. I'm working with a storyboard and just drag/dropping the views onto it and connecting it to classes I create. So...what newbie mistake am I making? What am I missing? I am working with xCode 4.4, so is this just different code than what I'm finding in these searches? Any help or advice would be greatly appreciated.
You can perform this by using Story Board only and not having to have a separate nib file for the PolicyInfoViewController... It would probably easier for you to do it this way.
so in keeping the first line of code:
[self performSegueWithIdentifier:#"ShowPolicyInformation" sender:sender];
You would need to override this method to manipulate properties of the PolicyInfoViewController
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:#"ShowPolicyInformation"])
{
PolicyInfoViewController *pol = segue.destinationViewController;
pol.PropertyOne=txtOne.text;
pol.strPropertyTwo=txtTwo.text;
}
}
So what is happening here? First bit of code you are telling the control to perform the particular segue from story board. Second bit you are telling control what to do when a particular segue is called.

'performSegueWithIdentifier' is not working

I have created a segue in storyboard named "CreateGame".And called it with my viewController to Load CreateGameViewController using [self performSegueWithIdentifier:#"CreateGame" sender:nil] but is is not working.
it was working some time ago but suddenly it is not working.
I have taken a look of my code. My
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(#"Segue");
}
is being executed each time when i call [self performSegueWithIdentifier:#"CreateGame" sender:nil] and then CreateGameViewController's "viewDidLoad" is being executed (conformed by using NSLog(); statement) . but CreateGameViewController not showing on screen of iphone.
i am using NavigationController So type of segue is 'Push'. some times segue works or sometimes not.
Please help me out.
I have a strong feeling that you are doing something in your CreateGameViewController's "viewDidLoad" (may be some looping or some recursion function calling without end) . That would have prevent the screen appears. it would be more helpful if you can provide the code of CreateGameViewController's "viewDidLoad"

release after iPhone navigationController pushViewController

I am very confused at the following code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
RPSAdvisorViewController *pushThis = [[RPSAdvisorViewController alloc]init];
pushThis.opponentName = [opponentArray objectAtIndex:indexPath.row];
[self.navigationController pushViewController:pushThis animated:YES];
//[pushThis release];
}
The if the line [pushThis release] does not get commented out, the app would crash when I pop back out of that view. I thought I always need to released the viewControllers that I allocated, but this time the app won't let me.
I even tried testing for leaks in instruments like this without releasing pushThis, there are no leaks.
I am really confused, can some one tell me why I'm not suppose to release pushThis?
Edit1: The crash will produce this error message:
-[CALayer release]: message sent to deallocated instance 0x4e66b20
It appears that when the navigationController pops the view controller, it trys to send release to pushThis again, which was already released. If I don't release everything works perfectly, instruments does not show any leaks even if i repeatedly push and pop the view controller.
You have to release it because when you push view controller, navigation controller take ownership of that controller.
I think there might be some views hierarchy issue with your app.Can you please check that?
I can only guess that there is some problem with RPSAdvisorViewController. Can you try replacing it with a place-holder UIViewController and see what happens?

UITableView didSelectRowAtIndexPath called twice

Under certain circumstances, UITableView didSelectRowAtIndexPath is being called twice causing the error Pushing the same view controller instance more than once is not supported.
Here's are the sequence of events:
TableView::didSelectRowAtIndexPath.
TableView::viewWillDisappear.
PushedViewController::viewWillAppear.
TableView::didSelectRowAtIndexPath.
Error: Pushing the same view controller instance more than once is not supported'
The only thing worth noting is that the UITableView is loading images asynchronously, but that never calls didSelectRowAtIndexPath. Also, the PushedViewController is reused to avoid having to reload it each time a cell is selected in the UITableView.
Anyone have any idea what may be causing this?
Thanks.
I'm seeing this problem too, probably one out of a 1000 users gets affected, or less. I сan clearly see two didSelectRowAtIndexPath registering 50 ms one after another. My guess is that it is a bug in iOS - no new taps should be directed to old view once new view-controller has been pushed. Alas, it is likely up to us to write code guarding against this. Here's what I'm thinking:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
if (self.navigationController.topViewController != self)
return;
... do other stuff
}
Disable user interaction after the first "didSelectRow". It's possible for multiple taps to "stack up" during the transition.
It usually takes someone with amazing dexterity in their fingers to get this behavior, but still.
if you already created Storyboard Segue don't call;
[self performSegueWithIdentifier:#"TYPE" sender:self];
in this method;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
This occurs because of the segue you are using inside the didSelectRowAtIndexPath method. Ensure that this segue is created by ctrl dragging from the view button on top of the source view controller to destination view controller. The error occurs when you create the segue by ctrl dragging from the table view cell to destination view controller.
You do not need to change any of you code. Just delete the segue and create it in the correct way. Hope this solves your problem, if I got the question right.
Swift 5
In my case also helped to update the cells instead of this code:
tableView.reloadRows(at: [indexPath], with: .automatic)
to use this:
tableView.reloadData()

iOS / Xcode 4: View won't load

This is really frustrating as I've tinkered with previous versions of Xcode and have done this before but playing around with a new app now, it's not working for some reason.
I have the app open to a UITableView and want it to load to a detail UIView once I select a cell. However, when I choose a cell in the iPhone simulator, it just highlights the cell blue and doesn't load the view.
Here is the code I'm using the the RootViewController:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
WorkoutViewController *workoutViewController;
workoutViewController = [[WorkoutViewController alloc] initWithNibName:#"WorkoutViewController" bundle:nil];
workoutViewController.workoutName = [workouts objectAtIndex:indexPath.row];
[self.navigationController pushViewController:workoutViewController animated:YES];
[workoutViewController release];
workoutViewController = nil;
I have the view linked to the File Owner in the WorkoutViewController.xib file. When I put in a breakpoint at #implementation WorkoutViewController, it does get to that breakpoint but it goes to the #synthesize line and then jumps right back out to [self.navigationController ...etc]; and never returns back to the WorkoutViewController.m file.
I would guess that you didn't set the ViewController to be the TableView's delegate. To check, open your ViewController xib-file and rightclick FilesOwner. Under Referencing Outlet you would usually have both delegate and data source" connected to your TableView. If that is not the case, drag New Referencing Outlet to your TableView.
If I'm wrong and they are all connected, you might want put a breakpoint at the beginning of your didSelectRowAtIndexPath method. Does the debugger stop there, once you select a row?
It might also be worth mentioning that a breakpoint at #implementation usually doesn't make much sense, you would rather want to place it in a method like init. Also, even though you are using Xcode 4 now, this is unlikely to be the cause of your problem, it looks more like an implementation issue.
Hope this helps, if you need further help just let me know!
Doh! Problem resolved. I had forgotten to actually put the RootViewController into a navigation controller on the MainWindow.xib. Appreciate the responses.