MKMapView crash on iPod when Re-enter in view - objective-c

I use MKMapView it works fine on iPhone, iPad and simulators but in iPod it crash when i second time enter in the view(first time it work fine). I have tried this but it is not work for me:
-(void) backButtonAction
{
[_mapView setDelegate:nil];
[self.navigationController popViewControllerAnimated:YES];
}
When I try to execute the code on an iPod(go second time on view) .I get an error ( EXC_BAD_ACCESS(code=EXC_ARM_DA_ALIGN,address=0x494f6055) )

By this solution didUpdateUserLocation method is not called and you are not able to get user location internally from didUpdateUserLocation method but until Apple not fixes it.This is the only solution i got from the link EXC_BAD_ACCESS at lauch for EAGLContext renderbufferStorage: fromDrawable: in Cocos2d app whie debugging
which i do and remove the crash.
In Xcode, go to Product -> Scheme -> Edit Scheme ... And for the Run Debug configuration (on left side) choose "Options" (on right side) and configure "GPU Frame Capture" as Disabled.

Related

subclass of UIViewController is unable to call loadView method

i have a subclass of UIViewController, and when it is called from another class the app just freezes - i used the Xcode debugger and figured that when I'm trying to access the class's view property the app freeze. another weird thing is that when i type in the debugger control panel: "po objectOfTheProblematicClass.view" the debugger stops responding.
the code I used was similar to this:
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:[NSBundle mainBundle]];
WTStickyViewController *stickyVC = [sb instantiateViewControllerWithIdentifier:#"WTStickyViewController"];
stickyVC.sticky = sticky;
// Setup view controller containment:
[self.parentViewController addChildViewController:stickyVC];
self.containerView = self.parentViewController.view;
[self.containerView addSubview:stickyVC.view];
WTStickyViewController is the subclass of UIViewController. the app freezes when it reaches
[self.containerView addSubview:stickyVC.view];
but it's because this is the first time that stickyVC.view is called.
if for example i would put somewhere in the code
UIView *viewForExample = stickyVC.view;
the app would freeze there.
the exact same app works fine when compiled on a device with iOS 8 but has this problem with iOS 9.
if anyone knows why is this happening and if there is a solution it will be great. thank you.
I was having a similar issue and it was absolutely maddening. The CPU went to around 100% in the resource monitor during debug as the app deadlocked. Printing to console or just generally accessing the view controller's view property caused this behavior. Ultimately, what 'fixed' it for me was removing it from the base localization file. I know that doesn't make sense, but I'll elaborate as best as I can.
I'm maintaining a legacy universal app that has 2 'main' storyboards called Main_iPhone and Main_iPad, which as you can probably guess are the loaded dynamically based on what device you're launching on. I noticed that only the iPhone nib view was deadlocking as described, and iPad was loading fine. The only thing I could tell as that the iPhone storyboard had localization enabled while the iPad storyboard had not. So here's the steps I took loosely to remove it from base localization (you may want to do this in a separate branch/sandbox to make sure this works before deleting project references):
Right click the problematic view and/or storyboard in question, show in finder. For me it was inside the Base.lproj folder as expected.
[Re]move the file to a different directory so Xcode can not find the link the project (file goes red in file browser). Press delete to remove the file from the project file's reference from the project itself.
Add the file back at the new location in your repository/project structure so Xcode picks it up as a new file. Ensure all of your references to the file are updated to the new location.
Verify your storyboard/xib file is not localized anymore, clean project, re-run and see if the issue is still there (see image).
You can also just update the file location using the update location button in the file properties view on the right side (see other image).
Don't know if this will fix it, but I thought I'd share what helped me in the chance that it helps others as well.
A bug report was sent to apple and hopefully it will be fixed soon - the problem is indeed with Xcode 7.
If you are encountering a similar problem, it can be solved by doing one of the following:
1) Use Xcode 6.4, at least until apple fixes this bug.
2) Rebuild the problematic view in the storyboard.
I will post the radar link once I got a chance to speak with my manager about it...

How to set PresentingViewController with current ViewController in iOS 7+

In my iOS 7+ app I'm using the latest version of Harpy, which perform an app version check and present an alert if there's a new version of my app available in the App Store.
Due to the structure of my app, I'm facing this issue in the debugger:
Attempt to present <UIAlertController: 0x144538530> on <DCLoginViewController: 0x14460c1a0> whose view is not in the window hierarchy!
this is because harpy is configured in the AppDelegate and has a parameter that define the presentingViewController:
[[Harpy sharedInstance] setPresentingViewController:_window.rootViewController];
I believe the issues arise because my app check if the user is already logged in, if so, instead of presenting the DCLoginViewController, it jumps to the next view which is "LoadingViewController".
How can I set the presentingViewController to be this LoadingViewController or even the ViewController currently on screen at execution time?
Thanks for your help.
You don't have to launch Harpy in the AppDelegate. You can launch it after LoadingViewController has loaded. It's only recommended to launch it in the AppDelegate as the idea is to show the alert as soon as the app is loaded. It's more of a UX thing than anything else.

App crashing without errors

In my app, I have four buttons. When I press two of the four buttons, the app freezes. The weird thing is that no errors appear and there is nothing in the debugger window. I am new to iOS development, so I have no idea how to fix this. The app worked fine before the app started crashing, and I didn't alter any code, so I don't know what is going on. Can someone help me out?
Here is the code for where the button is pushed. It has been working fine, so I don't know why it doesn't work all of the sudden:
- (IBAction)showMapView:(id)sender
{
P2OViewController *pvc = [[P2OViewController alloc]init];
[self.navigationController pushViewController:pvc
animated:YES];
}
- (IBAction)showTableView:(id)sender
{
TableViewController *tableView = [[TableViewController alloc]init];
[self.navigationController pushViewController:tableView
animated:YES];
}
So I added global breakpoints, and nothing is happening. The app is still running, and the debugger navigator says it is still running. So I guess the app is freezing, and not crashing. I have no idea how to fix this.
Seems like a memory problem.Instead of creating a p20viewcontroller object and tableviewcontroller object on every button click,try creating these objects only once somewhere in the start of the program.
the button click should only contain the code to navigate to the next screen.Not creating a new object on every button click.
I'd suggest you check the connections between your IBActions and your code. Unexplained errors like this can be caused by missing or incorrect connections in IB.

presentViewController: crash on iOS <6 (AutoLayout)

This is a weird crash I am getting. The crash happens when I press a button that goes to a certain ViewController. The line which it crashes on is:
DestinationInformationViewController *info = [[DestinationInformationViewController alloc] init];
[info setModalTransitionStyle: UIModalTransitionStyleCrossDissolve];
[self presentViewController:info animated:YES completion: nil]; // CRASHES HERE
[info release];
The crash trace is:
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x3758288f 0x35287259 0x37582789 0x375827ab 0x3153d54d 0x3153d6bb 0x3153d423 0x314ce001 0x3143c3c7 0x31319c59 0x3128fc17 0x3129a267 0x3129a1d5 0x3133959b 0x31338367 0x84091 0x374dc3fd 0x31271e07 0x31271dc3 0x31271da1 0x31271b11 0x31272449 0x3127092b 0x31270319 0x31256695 0x31255f3b 0x33c9822b 0x37556523 0x375564c5 0x37555313 0x374d84a5 0x374d836d 0x33c97439 0x31284cd5 0x82bb3 0x71200)
terminate called throwing an exception(gdb) Could not instantiate class named NSLayoutConstraint
NOTE: This crashes on my iPhone 4 iOS 5.1 but not on my iPhone 4S iOS 6 Beta 2
I believe this is an issue with Xcode's new interface builder. Did you happen to build your .xib using Xcode 4.5's interface builder? I've run into this same problem just now, and I think that's the problem. My app runs on iOS 6, but not anything older.
And you need to make sure you turn off Use Auto Layout for your xibs.
That can be done by:
Open your xib.
Go to the File Inspector tab.
Find the Interface Builder Document section on the right toolbar.
Uncheck the Use Auto Layout option.
I had the same problem when I downloaded new XCode update and IOS6 SDK. Here's how I solved it:
Select the Interface builder file (whether xib or storyboard file) where your error occurs.
In assistant editor on the right in XCode, select the first tab from the left, and there is a checkbox for option "Use Autolayout" like on the screenshot above.
Uncheck the checkbox.
Nagaraja asks "How to resolve the same if we are not using xib? I ran into exactly this problem. I created a controller with a xib, and then I decided to remove the xib file. The crash did not go away. The problem was that I needed to implement
- (void) loadView
in my controller class. Once I implemented this method the problem got solved.
Another possible reason for a crash with presentViewController is having something in the nib connected to a variable that is no longer there - the variable either having it's name changed or it was deleted.

Application crashes while logging out in iPAD

My question is specific to iPAD, and I also aware of the basic memory management of iOS, but I am having a different problem.
As I have build an application where I have several UIViewControllers and UIViews,
I have a loginController thats gets called when I launch the App.
My MainView is a single screen with all the ViewController loaded and placed at their respective places and the app runs fine and smoothly.
Problem:
Problem comes when I logout, most of the time my App crashes by saying EXC_BAD on the
[super dealloc] line of my mainView controller.
As for now on I have added a custom function cleanUP in all my viewControllers that gets called when user logout from the app.
Is this the right approach ?
As I know that we can clean up in our didload etc. function and the dealloc gets called too.
but here i have an iPAD when my all viewControllers are just open in front of me, They will be closed or not visible when I logout from the App.
So how to approach on my crash issue and How to manage memory here in my iPAD?
The best way I know to resolve bad-access problems is to use Instruments with the Zombie tool. As you probably know, when you get a bad access issue, is because you try to access to an object that is deallocated.
Try go to Product -> Profile and choose Zombie. Hit record and reproduce your crash. then inspect the pointer to the object that produced that crash and look for the retain count.