UITextSelectionView name unrecognized selector using SpriteKit and UITextView
I have an app that works fine with iOS 8.0, before upgrading to 8.1. When I create a UITextView inside SpriteKit game, I get the following error:
-[UITextSelectionView name]: unrecognized selector sent to instance 0x7f96ee6bdfa0
This happens if I create an object in code or place a UITextView in my xib file.
The hierarchy looks like this:
UIViewController (self.view is SKView) -> UIView -> UITextView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
UITextView *test = [[UITextView alloc] init];
}
return self;
}
Any ideas what the problem might be and why is it showing up so suddenly?
source to share
The problem was using performSelector: withObject: afterDelay: in the SpriteKit scene. Once I replaced those occurrences with SKAction, it solved the UITextView issue.
Old code:
[self performSelector:@selector(methodName) withObject:nil afterDelay:1.0];
New code:
SKAction *action = [SKAction performSelector:@selector(methodName) onTarget:self];
SKAction *wait = [SKAction waitForDuration:1.0];
SKAction *sequence = [SKAction sequence:@[wait, action]];
[self runAction:sequence];
source to share
I had a similar issue crashing on iOS 8.1. But instead of crashing when calling [UITextSelectionView name], the log tells me that it crashes instead of [GKLocalPlayerInternal name].
And oddly enough, the problem disappears when I replace [self performSelector ...] (where self is SKNode), doing the same with [SKAction performSelector ...].
This seems to be a not-too-obvious bug in iOS 8.1.
source to share