This works on the iPhone BTW (Both running iOS 5.1)
My app freezes when I call [self dismissModalViewControllerAnimated:NO];
I have tried many different approaches:
My code how 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 from a done button
-(void) done:(id)sender
{
[delegate doneEditing:inputText.text];
}
I have tried dismissing the modal in my done function
I have tried it in both places with self
I have 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 a user clicks a UITextView I use to open a new ModalViewController to allow the user more space to type large amounts of text, after completion the user presses done and I call the delegate method to put the text on the original form.
If I change animated to yes in any of the above given cases it still doesn’t work but instead of freezing I get the 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…
Since its iPad maybe you can use a UIPopOverController when you want to present the view. Try creating a UIPopOverController initiating it with the view controller for your modal view. You can set the size and where it will popover from. You can set the class it is called from to be the delegate for the view so that you can get notifications.
Hope this helps