App stalls - no crash, no error - iphone

It is worth noting that this part of the app (this option from the main menu) was working perfectly before. I then programmed the next option from the main menu, and now this one is not working anymore.
I know the code I've written works, but there is something wrong with either the class or the xib, because it worked when I switched it to call a different class/xib from:
UIViewController *nextController = [[OneMethodController alloc] initWithNibName:#"OneMethodController" bundle:nil];
to:
UIViewController *nextController = [[SecondMethodController alloc] initWithNibName:#"SecondMethodController" bundle:nil];
When I try to load the first class/xib (which used to work, as I said), the app just stalls indefinitely. There is no error and the app does not crash.
Any ideas? THANKS!!

Note that *nextController should most likely be initialized as
SecondMethodController *nextController = [[SecondMethodController alloc] init . . .
And not as
UIViewController *nextController = [[SecondMethodController alloc] init . . .

The issue was not with the XIB but with the viewDidLoad of that XIB's class. Thanks #cool_me5000 for your help with this.

Related

I am using FBLogInView to implement FBLogin. loginViewFetchedUserInfo not getting called

I have spent several hours. Read up everything relevant I could find on the web, but haven't been able to resolve this. I am using FBLoginView per instructions provided in https://developers.facebook.com/docs/ios/login-ui-control/
I can see FBLogin button. I click on it. It logs me in. I see callbacks loginViewShowingLoggedInUser and loginViewShowingLoggedOutUser getting called. The problem is loginViewFetchedUserInfo not getting called. So, I am unable to get any information about the user (such as name, userID, email etc).
Here is the code I am using:
CGRect loginFrame=CGRectMake(MARGIN,currentFrame.size.height-LOGINBUTTONHEIGHT,50 , 20);//width, height don't matter
FBLoginView * FBLoginView1 = [[FBLoginView alloc] init];
FBLoginView1.readPermissions = #[#"email",
#"basic_info",
#"user_location",
#"user_birthday",
#"user_likes"];
FBLoginView1.frame = loginFrame;
FBLoginView1.delegate = self;
[[self view] addSubview:FBLoginView1];
[FBLoginView1 sizeToFit];
Please help me.
It may help: I have get the same issue. For me the solution was I did not correctly assign the delegate.
Programmatically, Facebook propose you to
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.delegate = self;
But as I have set up the view via the storyboard, I could not do that. So in the inspector connector, I connect the delegate outlet to the File's Owner (I just wired the outlet the scene).
Hope it helps :)
I found the solution. Actually, loginViewFetchedUserInfo is called after loginViewShowingLoggedInUser. I was not getting loginViewFetchedUserInfo because I was dismissing modalviewcontroller from loginViewShowingLoggedInUser. So, it was not around to get loginViewFetchedUserInfo. If I don't dismiss the modalviewcontroller, I get loginViewFetchedUserInfo.
Here are the details of the solution.
I am creating FBLoginView in ViewDidLoad of a LoginViewcontroller (name of the class I implemented).
I set the delegate when I create FBLoginView (inside ViewDidLoad function)
LoginViewController is presented using presentViewController function.
The problem was happening because I was dismissing the view controller in loginViewShowingLoggedInUser. So it was not around to receive loginViewFetchedUserInfo ( loginViewFetchedUserInfo is called after loginViewShowingLoggedInUser).
The solution that worked for me is to dismiss LoginViewcontroller from loginViewFetchedUserInfo.
Hope the details helps others.
I had the same problem. In my case, delegate was not set properly. Ensure you the following lines in logincontroller:
FBLoginView *loginView = [[FBLoginView alloc] init];
loginView.delegate = self;

pushViewController Not Working on iOS 5 (OK on iOS 6)

I have a UINavigationController that displays several buttons on screen. They all simply use the line:
myViewController *newView = [[myViewController alloc] initWithNibName:#"myViewController"
bundle:nil];
[[self navigationController] pushViewController:newView animated:YES];
to transition to the next view. I have one such view controller however that results in a crash at this very line ONLY on iOS 5. It works perfectly fine on iOS 6. I am baffled. There are no real details to the crash. It is a SIGABRT that highlights the main.m line:
exitStatus = UIApplicationMain( argc, argv, nil, NSStringFromClass([ApplicationDelegate class]));
I have no clue...
You Need to unCheck the Auto Layout.
And make sure you are changing here also.. select ios 5.1
Try this line:
myViewController *newView = [[myViewController alloc] initWithNibName:#"myViewController"
bundle:[NSBundle mainBundle]];
in place of:
myViewController *newView = [[myViewController alloc] initWithNibName:#"myViewController"
bundle:nil];
I have experimented a similar issue an here are the steps that I feel need to be considered:
(if you are using xib file) like Venkat Manohar Perepa mentioned, check that Use Auto Layout is turned off as it is an iOS 6 specific feature.
(if you are using xib file) look at the content of the xib file that is used when presenting your viewcontroller and check that there is no class that are iOS6 specific (e.g: NSLayoutConstraint)
Last (and that was the issue I was facing) you should check if the crash appear on a device that has iOS5 installed. If it doesn't but still crash on the simulator remove the application you have installed by choosing iPhone Simulator > Reset Content and Settings.

Program received signal EXC_BAD_ACCESS : Simple Navigation

This is really basic. But I have no idea where I am going wrong.
I am on the ARC mode and all I have done is written the following code in my AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions function
homePage *hp = [[homePage alloc] init];
UINavigationController *navcon = [[UINavigationController alloc] initWithRootViewController:hp];
The home page gets loaded up correctly and there is a button on the homePage which when clicked should trigger a pressedPlay: wired up correctly in the .xib. But as soon as the button is clicked the program crashes with the error: EXC_BAD_ACCESS. Any help please?
This usually means something had a reference count of zero and then you tried to use it.
I bet it is something to do with whatever your button touch event is trying to process. Step through the code and see exactly at what point the crash happens.
Try this
homePage *hp = [[homePage alloc] initWithNibName:#"homePage" bundle:nil];
UINavigationController *navcon = [[UINavigationController alloc] initWithRootViewController:hp];
And follow naming conventions instead of homePage it should be HomePage.
I found a fix to the problem. With ARC the view to be pushed into the navigation controller must have a strong property associated with it, otherwise it is released.

modal views not working when compiling in xcode 4

I've just updated to Xcode 4 had a few problems getting the app to compile but they are sorted now. However I have a major problem with the navigation of my app. I have various buttons that all fire actions that should display different modal windows using code similar to the following
- (IBAction)showMyJobs:(id)sender {
UIViewController *myJobsView = [[MyJobsView alloc] initWithNibName:#"MyJobsView" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myJobsView];
[self presentModalViewController:navigationController animated:YES];
[myJobsView release];
}
Now all this code was working perfectly before I compiled the app in xcode 4. What happens now is that the code seems to run (see it running in the debugger) but nothing gets displayed. Can anyone point me in the right direction as to whats going on.
I don't get any errors/warnings while compiling, nothing. It's driving me mad!
Any help would be greatly appreciated.
Just a stab in the dark, but try:
[self.navigationController presentModalViewController:navigationController animated:YES];
This is really late, but for what its worth - you need to release the navigation controller first and then the view controller.

Strange Exc Bad Access when using Init, PushViewController, Release. Anything wrong with this code?

Maybe I've been looking at this for too long ;) My app has a NavigationController and several ViewControllers. From one of the ViewControllers two levels down (mainViewController), loaded from the rootViewController, I have the code below. After the PushViewController to the dataViewController and back (e.g. back Button pressed), the app crashes.
The dataViewController loads just fine, but when the back button of the navigationController is tapped, the App crashes with Object Exception. If I remove:
[dataViewController release];
the app works fine. It's strange because the dataViewController is init'ed in the same method.
Any ideas?
- (void) locationPage
{
[[NSNotificationCenter defaultCenter] postNotificationName:#"NotifyRemoveMap" object:nil];
MyAppDelegate *app = [[UIApplication sharedApplication] delegate];
UINavigationController *navigation = app.navigationCantroller;
[navigation popToRootViewControllerAnimated:NO];
DataViewController *dataViewController = [[DataViewController alloc] initWithNibName:#"DataView" bundle:nil];
[dataViewController setCategoryId:category];
MyLanguage *lang = app.lang;
Mylocation *location = [lang locationForCategoryId:category];
dataViewController.title = location.name;
NSArray *locationArray = [lang locations];
dataViewController.locations = locationArray;
[navigation pushViewController:dataViewController animated:YES];
[dataViewController release]; // With this removed, app doesn't crash
}
Haven't even read your post. If it's Exec-Bad-Access, I have 2 words for you:
Enable NSZombies.
Follow this link: (it explains everything you need to know to fix any bad access issue)
Phone Memory Debug with NSZombie and Instruments
Cheers!
The problem probably arises when the dataViewController gets popped and you try to access something on it - it is already released then. You might check the console for more details - better yet, run in debug mode (debug configuration and running with debugger).
You can edit your question to show some code that is run with the back button.
You talk about releasing dataViewController but your code says detailsViewController. Did you copy and paste incorrectly or is that the mistake?
You should consider not to use app.navigationController but self.navigationController. Cleaner design. Less dependencies on the app delegate, which too often is used as a frankensteinobject that knows too much.