While the following line works on iPhone 7.1/8.1, on iPad it only works on 7.1. On 8.1 the memory usage goes up and up until it crashes:
[self.navigationController pushViewController:detailController animated:YES];
This line happens here:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
OBDialogDetailViewController* detailController = [[OBDialogDetailViewController alloc] initWithOption:(OBSelectionFilterOption*)option];
[self animateChangeForView:nil atIndexPath:indexPath toRect:CGRectMake(0, 0, 0, 0) andNewHeight:0];
if (self.navigationController)
{
[self.navigationController pushViewController:detailController animated:YES];
}
}
Since I just got responsible for this application, thas has grown over years and has no documentation, I'm a little bit desperate. I searched and tried multiple answeres and solutions for two days now.
Please tell me what more information I can provide.
It will not happen in all scenarios. But couple of things I would like to mention :
I was trying to play an encrypted video (heavy file) on the destination viewcontroller of UINavigationController. Method which decrypts and loads the video on that viewcontroller's view takes time when I load it in viewDidLoad. In that case, please use the following code.
[self performSelectorInBackground:#selector(createVideoPlayer) withObject:nil];
[self performSelectorInBackground:#selector(createVideoPlayerControllerView) withObject:nil];
Please refer this link to manage memory issues even if you are using ARC.
This might not answer your question directly, but will certainly help you to debug. Please post whatever solution you get. Thanks.
Related
I think there's an issue with the MFMailComposeViewController in iOS9, at least on my new iPad mini 4.
Even using the simplest test code I doesn't work. For example, using:
if(![MFMailComposeViewController canSendMail]) {
return;
}
MFMailComposeViewController *controller = [MFMailComposeViewController new];
controller.mailComposeDelegate = self;
[controller setSubject:#"Test"];
[controller setMessageBody:#"Test" isHTML:FALSE];
[self presentViewController:controller animated:TRUE completion:^{
}];
The App becomes completely unresponsive, NOTHING happens on the screen, I see no draft e-mail or something like that.
Important things to know:
YES, my device can send mail, I've used the default canSendMail check
I've tried strong-referencing the controller but it had no effect
The exact same code works perfectly on another iPad running iOS8
In the simulator it DOES show the draft but closes immediately saying that "MailCompositionService suddenly quit"
Anybody any ideas?
Ok I created a complete barebone test-App and found out it DID work there so something else was the issue. I finally discovered the issue was that the App showed a tableview with about 50 rows (I did use recycling) but that created a memory issue... (I did check with Instruments but no leaks).
Anyway, I found out if I present the mailcontroller when NOT also showing the tableview it had no issues at all.. You'd think that the iPad mini 4 would be capable of both.
So the lesson learned is, create a complete barebone test-app first before posting questions on SO..
I´m new to Xcode but I keep on making some small apps to learn. I have run into a problem that only sometimes occurs with the message "Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!" and the app then crash.
I have searched around and found some possible answers but no luck for me yet.
My code for back is:
- (IBAction)Back {
UIViewController *back = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:back animated:NO completion:NULL];
I understand that the problem is that I try to go from one viewcontroller to another before the presentation of the viewcontroller is done.
The strangest thing is that this sometimes isn´t any problem and the app works flawlessly.
Ok, I think you have trouble with the concept of navigation in iOS. First take a look at iOS Human Interface Guidelines: Navigation, and then read: Navigate with UINavigationController in iOS7 (don't worry about ios 7 or 8, they're both similar)
Overall, I really recommend watching Stanford's Developing iOS 7 apps for iPhone or following the newest one: Developing iOS 8 Apps with Swift to learn!
I'm using GCD to make sure this happens on the main thread, but even that doesn't fix the issue.
- (void)showCat:(NSNotification *)notification {
dispatch_async(dispatch_get_main_queue(), ^{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UINavigationController *navVC = [storyboard instantiateViewControllerWithIdentifier:#"Cat"];
[self presentViewController:navVC animated:YES completion:^{
//this never happens on iOS7
}];
});
}
navVC is not nil.
Works fine on iOS8. On iOS7 the app just hangs. Memory usage continuously goes up until it crashes due to memory pressure.
What else could be the cause of this? presentViewController works fine in other areas of the app. This code is called when a notification is received.
Actually turned out there was some recursive code in viewDidLayoutSubviews of the presented view controller. Thanks to #matt for the tip. Not sure why this isn't also an issue in iOS8, but nevertheless the problem is fixed.
Goes to show that actually offering advice even if you don't have the entire code base of the project in front of you can still be helpful, rather than simply downvoting from your high horse.
I developed my first app and still learning. Just updated Xcode 5 yesterday and my iPhone 5 is running iOS 7.1. I am now working on understanding the Instruments tool to analyze my app. I am using the Leak profile in Instruments and have come across a retain cycle and leak which I can't figure out. Appreciate any help I can get to understand a) how to pinpoint the bug and b) what I did wrong and how to avoid it in the future.
In my app, I am using the camera to take a pic. While the camera is up, I tapped on the screen to focus and that is when I noticed the leak pop up in Instruments. Looks like there is a retain cycle not in my code (if I understand correctly) and a root leak in my code which I don't understand.
I am using ARC, so I should not have to release "picker" in the part of my code that Instruments is pointing me to (part 2 below, with code).
What can I do about the retain cycle. It is not in my code, but am I still the cause of it? Does it stem from the "root leak?" If I am NOT responsible for it, what's should I do about it?
My only code in this stack trace does not help me understand where the leak is coming from. The line is Instruments points me to in my code is [picker dismissViewControllerAnimated:YES completion:nil]; in my imagePickerController:didFinishPickingMediaWithInfo: method. I am pasting the code below.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *pickerImage = [info objectForKey:
UIImagePickerControllerOriginalImage];
_imageView.image = pickerImage;
[picker dismissViewControllerAnimated:YES completion:nil]; // <--- mem-leak
}
EDIT - Code where I create my UIImagePickerController.
- (IBAction)snapPicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
// If the camera button was tapped AND we have a camera, use it...
if ((sender == _cameraButton) && [UIImagePickerController
isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
} else {
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
imagePicker.delegate = self;
// bring up the image picker view
[self presentViewController:imagePicker animated:YES completion:nil];
}
Here's my theory: what you've encountered is evidently a bug (or flaw) in Apple's own code, and all you can do is laugh maniacally and forget about it.
To test my theory, I ran my own code, written totally separately and at a different time. It does almost the same thing your code does: it lets the user take a picture, and puts the image into the interface. Here's my code:
https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch17p702takeAPicture/ch30p962takeAPicture/ViewController.m
I ran my code under Instruments with the Leaks instrument, and guess what? I saw the same issues you did.
Naturally, I then started searching on Stack Overflow, and all of this turns out to be old ground. For example:
UIImagePickerController memory leak on iOS5
Even Apple's own sample code, called PhotoPicker (or Using UIImagePickerController to Select Pictures and Take Photos) has the same leak.
I am trying to adapt an existing application to an iPad app. The application has a main view that calls View2 that is in "View2.xib". Everything has been working well, until I entered the following:
if(!view2Controller)
{
view2Controller = [[View2Controller alloc] initWithWindowNibName:#"View2"];
}
[view2Controller showWindow:self];
This works in my original Cocoa program, but in the iPad application it is currently returning a warning: "Thread1: Program received signal "SIGBRT" While working with it, I've also received a message Method -initWithWindowNibName not found.
Similarly, I have the same problem with the method showWindow.
I wonder how it is that this problem shows up when I try to convert it to an iPad app.
I've run out of ideas to check and would appreciate some assistance.
You will need to change it to the following
if(!view2Controller)
{
view2Controller = [[UIViewController alloc] initWithNibName:#"View2" bundle:nil]
}
//If you are in a view controller use
[self presentModalViewController:view2Controller animated:YES];