I am having a problem that I can't seem to figure out.
What I have setup:
- A custom UITableViewCell that has multiple textfields in it. Similar to how Apple has it setup when adding a new address for someone in contacts.
- The table with the custom cell is being presented as a modal view. This table view also has other cells that are generic (i.e. not the custom cell stated in 1. ).
- The presented modal view has a toolbar at the top, which contains a done button. When done is pressed the modal view sends a call back to its delegate and dismisses.
The problem that I am having: When the user selects a UITextField and starts to edit the UIKeyboard is presented (obviously right?). If the keyboard is open, and the user selects "done" on the toolbar (as stated in 3. ), the app crashes because the parent view is trying to dismiss the modal view (modal view containing the keyboard) while the keyboard is open.
High level it seems like it should work like this:
User clicks "done" in toolbar -> check if UIKeyboard is open -> if open, close else dismiss modal view
But it hasn't been that easy.
I have been pulling my hair out trying to find a viable work around for this and nothings seems to work.
Any suggestions would be very appreciated.
Edit
Here is the crash log:
2011-12-22 16:03:09.021 Renshaw[2308:5f43] bool _WebTryThreadLock(bool), 0xad7a9e0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
1 _ZL17_WebTryThreadLockb
2 WebThreadLock
3 -[UITextRangeImpl isEmpty]
4 -[UITextRange(UITextSelectionAdditions) _isCaret]
5 -[UITextSelectionView setCaretBlinks:]
6 -[UIKeyboardImpl setCaretBlinks:]
7 -[UIKeyboardImpl setDelegate:force:]
8 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
9 -[UIResponder _finishResignFirstResponder]
10 -[UIResponder resignFirstResponder]
11 -[UITextField resignFirstResponder]
12 -[UIView(UITextField) endEditing:]
13 -[UIWindowController _prepareKeyboardForTransition:fromView:]
14 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]
15 -[UIViewController _dismissViewControllerWithTransition:from:completion:]
16 -[UIViewController dismissViewControllerWithTransition:completion:]
17 -[UIViewController dismissViewControllerWithTransition:completion:]
18 -[ListingsViewController postSearch:allObjects:constrainedList:]
19 -[FilterViewController searchObjects]
20 -[NSObject performSelector:withObject:]
21 -[MBProgressHUD launchExecution]
22 -[NSThread main]
23 __NSThread__main__
24 _pthread_start
25 thread_start
[Switching to process 10499 thread 0x2903]
[Switching to process 10499 thread 0x2903]