I have an app that worked perfectly fine with iOS 8.0, until the switch to 8.1. When I create a UITextView inside of a SpriteKit game I get the following error:
-[UITextSelectionView name]: unrecognized selector sent to instance 0x7f96ee6bdfa0
This occurs if I create the object in code or place a UITextView in my xib file.
The hierarchy looks like this:
UIViewController (self.view is a 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 it appeared so suddenly?
The problem ended up being the use of performSelector:withObject:afterDelay: within a SpriteKit scene. Once I replaced these occurrences with an SKAction, it solved the UITextView problem.
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];
I had a similar problem with a crash turning up in iOS 8.1. But instead of crashing when calling [UITextSelectionView name] the log tells me that it crashes on [GKLocalPlayerInternal name] instead.
And strangely enough the problem disappears when I replace [self performSelector...] (where self is a SKNode) with doing the same with [SKAction performSelector...].
Seems to be a not too obvious bug in iOS 8.1.
I found a solution what works.
UITextView *textView = [UITextView .....];
**textView.selectable = NO;**
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.