navigationController crash - iphone

I have a question about iPhone develop
CarDetailDetail *myview = [[[CarDetailDetail alloc] init] autorelease];
myview.detailMaintainID = self.detailMaintainID;
[[self navigationController] pushViewController:myview animated:YES];
this is work fine in iPhone 4 (iOS 4.3) and iPhone 3gs (iOS 5.X)
but iPod touch (iOS 4.2) will crash when I pop back one or two times,
memory warning will appear and has bad access error
but when I not release *myview (remove autorelease keyword) , iPod works fine...
I don't know why , some one can help me? thanks

Experiment with the YES/NO flag on the pop animation
If you find that you are getting no crash on your problem device with NO pop animation it probably indicates a timing issue of some sort.
In other words a block or web thread is trying to hit a view controller which has been deallocated already.
post your your console logs in the question too for more help.

try doing this
CarDetailDetail *myview = [[CarDetailDetail alloc] initWithNibName:<name of view contrlle> bundle:nil];
//Remove this bit of code myview.detailMaintainID = self.detailMaintainID;
[[self navigationController] pushViewController:myview animated:YES];
[myview release];

Related

Missing keyboard in MFMailComposeViewController

I've got this code working well for months (on iOS 5.1), but I didn't check it for a long time and now (probably iOS 6.0 issue) I've noticed that my MFMailComposeViewController doesn't show the keyboard even when focusing textfields like message body or recipients.
The strange thing is that it reacts on taps, so i can set cursor on 'To' or 'Subject' and the cursor appears, or I'm able to hold the tap to make the zooming glass pop up. But no keyboard :(
SCREENSHOT OF THIS
Here's the code I'm using:
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[self presentModalViewController:mailer animated:YES];
I've been searching a lot about this and found something that deals with
[self resignFirstResponder] or [mailer becomeFirstResponder], but it didn't work.
If I add this code before or after presenting controller
NSLog(#"mailer become %d", [mailer canBecomeFirstResponder]);
It shows 0, however, the
NSLog(#"self resign %d", [self resignFirstResponder]);
shows 1, but it was 0 too before i added the
- (BOOL)canResignFirstResponder {
return YES;
}
Docs say it should return YES by default, so it's double strange.
If I create an empty project with such code it works well, but I can't really do this because my current project is quite huge.
Any help would be appreciated, getting stuck here...
Tested both on iPhone and iOS Simulator (both deployment target 5.1 and 6.0)
Just LOL. The problem was with the
[UIApplication sharedApplication] delegate] window] setWindowLevel:UIWindowLevelStatusBar + 1]
somewhere in my app. Seems like they changed keyboard windowLevel in iOS 6, so that now it's behind. I'm quite lazy to do so, but it would be interesting to know exact windowLevel of the keyboard window :)
Be careful with that!
Thanks to everyone for helping anyway!
If you want to show the keyboard, you must take the text box from the mailer and then send the message becomeFirstResponder.
However, there is not straight forward way to do that. When you touch the box of the message, does the keyboard appear?
For others who may have come up with this keyboard issue in the MailComposer this solution worked for me:
Present the view then call "becomefirstResponder" on the same
MFMailComposeViewController in the completion method.
MFMailComposeViewController* mailCon = [[MFMailComposeViewController alloc] init];
[self presentViewController:mailCon animated:NO completion:^{
[mailCon becomeFirstResponder];
}];

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.

How to remove from this Debugger warning [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Getting “Using two-stage rotation animation” warning with UIImagePickerController
In my iphone app i have a login screen after loging in i am navigating to a class ( i have tab barcontroller with 5 tabs here)
like this i am programmatically creating the tabbar
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *arrControllers = [[NSMutableArray alloc] initWithCapacity:5];
//Add PunchClock to tab View Controller
PunchClock* objPunchClock = [[PunchClock alloc] initWithTabBar];
NavigationController = [[UINavigationController alloc] initWithRootViewController:objPunchClock];
NavigationController.navigationBar.tintColor = [UIColor brownColor];
[arrControllers addObject:NavigationController];
[NavigationController release];
[objPunchClock release];
tabBarController .viewControllers = arrControllers;
[arrControllers release];
[self.view addSubview:[tabBarController view]];
after logging in while navigating to this class i am getting this Debugger warning
2012-07-07 12:09:27.988 WorkForce[1475:207] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
2012-07-07 12:09:28.074 WorkForce[1475:207] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate
what is it mean,,,how to remove this warning? please help me out
I have no idea what that error message means but when you get such a specific error message, it is often helpful to do a search with the entire error message in quotes to see if anyone else has encountered it.
Apparently they have. Please report back and tell us what it means.
The two-halves animation methods like willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: and willAnimateSecondHalfOfRotationToInterfaceOrientation:duration: are an older approach. If you've implemented these methods, they should be removed so that the one-step scheme (in this case, willAnimateRotationToInterfaceOrientation:duration:) can be used.

Please assist with modalViewController crash

My app is crashing when I dismiss a ModalViewController via:
[self.parentViewController dismissModalViewControllerAnimated:YES];
This modal view-controller ("MVC") is presented when a user clicks on one of the cells of a UINavigationController ("NavRoot") - here's the code for that:
MVC *modalView = [[MVC alloc] initWithNibName:#"MVC" bundle:nil];
[self.navigationController presentModalViewController: modalView animated:YES];
[modalView release];
The "modalView" which is loaded contains only 2 objects: a UIWebView object and a "DONE" button, which when clicked-on does the dissmissing via:
[self.parentViewController dismissModalViewControllerAnimated:YES];
Except when I click on "DONE" - the app crashes.
When I run Instruments with NSZombies I do see the retain count reaches -1 but I can't tell what's causing this over-release.
The only thing I found which solves the problem is to either add a "[modalView retain]" statement in "NavRoot" - which is the viewController doing the presenting of modalView:
MVC *modalView = [[MVC alloc] initWithNibName:#"MVC" bundle:nil];
[self.navigationController presentModalViewController: modalView animated:YES];
[modalView retain]; // <<== new 'retain' statement
[modalView release];
or just simply never releasing modalView in the first place:
MVC *modalView = [[MVC alloc] initWithNibName:#"MVC" bundle:nil];
[self.navigationController presentModalViewController: modalView animated:YES];
// commenting out the 'release':
// [modalView release];
Both of these options throw flags when I run "Analyze" ("Potential leak of an object allocated on line 34"...) but they do fix the problem.
Still, I worry about this causing the app to be rejected by Apple from the App Store.
Any ideas on what may be causing the over-release? Or how I might further try to isolate / identify the problem?
attaching an image of Instruments/Zombies report:
Are u using iOS 5? I had the same problem when I switched an app from ios4 to 5.
ParentViewController is now called presentingViewController
What you can do though is in your modal view just call [self dismissModalViewController] and it should dismiss itself. I'm not 100% about that and can't check as I'm not near my mac, but I recall reading it in the docs,
If you do
[self.navigationController presentModalViewController: modalView animated:YES];
Then you should dismiss it like
[self.navigationController dismissModalViewControllerAnimated:YES];
Rather than
[self.parentViewController dismissModalViewControllerAnimated:YES];
Where are you trying to dismiss the view from? The actual modalView or the parentView? It seems to me that you are trying to dismiss a modal view that has already been dismissed and subsequently released.
To dismiss a modalViewController I simply just do: [self dismissModalViewControllerAnimated:YES];.
[self dismissModalViewControllerAnimated:YES] does not work on iOS 5.
I have built a category that add presentingViewController on iOS 4. (It disables itself on iOS 5.)
Just include 2 files, and it works seamlessly.
Please see backward-modal.
I hope this benefits you as much as it does to me; It makes your code more clean!

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.