App freezes when modal view controller is disabled on iPad
This works on iPhone BTW (both iOS 5.1)
My application freezes when I call [self dismissModalViewControllerAnimated:NO];
I've tried many different approaches:
My code is as I have it now:
-(void) doneEditing:(NSString *)value
{
[multiLineText dismissModalViewControllerAnimated:NO];
self.currentActiveTextView.text = value;
self.currentActiveTextView = nil;
}
- (void)textViewDidBeginEditing:(UITextView *)textView
{
multiLineText = [[MultilineTextViewController alloc] init];
multiLineText.delegate = self;
multiLineText.text = textView.text;
self.currentActiveTextView = textView;
[self presentModalViewController:multiLineText animated:NO];
}
MultilineTextViewController.h
@protocol DoneEditing
-(void)doneEditing:(NSString*)value;
@end
@interface MultilineTextViewController : UIViewController
{
UITextView *inputText;
id<DoneEditing> delegate;
}
@property (nonatomic, strong) NSString *text;
@property (nonatomic, strong) id<DoneEditing> delegate;
@end
Function called with the made button
-(void) done:(id)sender
{
[delegate doneEditing:inputText.text];
}
I tried to dismiss modality in my executed function I tried this in both places on my own I also tried this in MultilineTextViewController
if ([[self parentViewController] respondsToSelector:@selector(dismissModalViewControllerAnimated:)]){
[[self parentViewController] dismissModalViewControllerAnimated:NO];
} else {
[[self presentingViewController] dismissViewControllerAnimated:NO completion:nil];
}
Just some history, when the user clicks on a button UITextView
that I use to open a new ModalViewController
one to allow the user more room to enter large amounts of text, after the user is finished clicking and I call the delegate method, put the text in the original form.
If I change animated to yes in any of the above cases it still doesn't work, but instead of freezing, I get NSInternalInconsistencyException
Attempting to begin a modal transition from <WorkflowViewController: 0xc6846b0> to <MultilineTextViewController: 0xc64b960> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed
Any ideas?
I can't seem to find a reason for this thing not to work ...
source to share
Since its an iPad, perhaps you can use UIPopOverController whenever you want to present a view. Try to create a UIPopOverController by initializing it with a view controller for your modal view. You can set the size and location from which it will appear. You can set the class it is called from to be a delegate for the view so you can receive notifications.
Hope it helps
source to share
I don't understand your line
[multiLineText dismissModalViewControllerAnimated:NO];
since multiLineText is your modal view controller firing must be called by the view controller representing it, i.e. in your first example (since you assigned a delegate to the view of the view controller)
[multiLineText.delegate dismissModalViewControllerAnimated:NO];
must work. You are setting the delegate to zero to avoid getting fired twice.
source to share