UITextView as its own delegate - infinite loop on keyboard select
UITextView as its own delegate - infinite loop on keyboard select
- Subject: UITextView as its own delegate - infinite loop on keyboard select
- From: Roland King <email@hidden>
- Date: Sat, 27 Feb 2010 21:39:17 +0800
I have a UITextView subclass which, when you touch it to start editing, hangs in an infinite loop before the keyboard comes up. The subclass sets itself as its own delegate in the constructor (because the subclass in this instance wants to capture editing ended events and deal with them internally).
I've stripped the class down to literally a subclass of UITextView which does nothing but set itself as delegate in the initWithRect: method (calling the superclass of course) and implements none of the delegate methods.
Hitting pause I found the trace often in respondsToSelector: so I overrode that to print out what selector was being requested and then just call the superclass implementation, below is 8 milliseconds worth of that trace, it's just asking about 2 selectors over and over again, looping.
2010-02-27 21:21:05.943 WhiteBoard[57954:207] Asking about selector: textViewDidChangeSelection:
2010-02-27 21:21:05.944 WhiteBoard[57954:207] Asking about selector: keyboardInputChangedSelection:
2010-02-27 21:21:05.947 WhiteBoard[57954:207] Asking about selector: textViewDidChangeSelection:
2010-02-27 21:21:05.947 WhiteBoard[57954:207] Asking about selector: keyboardInputChangedSelection:
2010-02-27 21:21:05.948 WhiteBoard[57954:207] Asking about selector: textViewDidChangeSelection:
2010-02-27 21:21:05.948 WhiteBoard[57954:207] Asking about selector: keyboardInputChangedSelection:
2010-02-27 21:21:05.949 WhiteBoard[57954:207] Asking about selector: textViewDidChangeSelection:
2010-02-27 21:21:05.949 WhiteBoard[57954:207] Asking about selector: keyboardInputChangedSelection:
2010-02-27 21:21:05.950 WhiteBoard[57954:207] Asking about selector: textViewDidChangeSelection:
2010-02-27 21:21:05.951 WhiteBoard[57954:207] Asking about selector: keyboardInputChangedSelection:
The stack trace at the point it does this is below - it starts at stackframe 10 only because I've trimmed off everything after the dummy respondsToSelector: call I put in which just NSLog()s, that takes 10 stack frames.
#10 0x003ad281 in -[UITextView keyboardInputChangedSelection:] ()
#11 0x0042f8dc in -[UIWebDocumentView keyboardInputChangedSelection:] ()
#12 0x003ef907 in -[UIKeyboardImpl callChangedSelection] ()
#13 0x003f5cdc in -[UIKeyboardImpl updateForChangedSelection] ()
#14 0x003f3857 in -[UIKeyboardImpl setDelegate:force:] ()
#15 0x003efeb5 in -[UIKeyboardImpl setDelegate:] ()
There's obviously workarounds. I could start adding do-nothing delegate methods to try and break this up. I could have another object be the delegate and just call back into the delegate method handling code in my UITextView subclass, but that's a crappy contract to force any user of this object to conform to.
I'm thinking to burn a support incident on this because it seems like wrong behaviour and I've found apple's support incident responses to be absolutely superb, before I do, is there something I have missed in the docs or elsewhere anyone know of which tells me what I'm doing is wrong or that if I want to be a self-delegate there are methods I must implement?
Thanks
Roland
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden