简体   繁体   English

NSOperation中显示的UIAlertView-视图控制器无响应

[英]UIAlertView shown in NSOperation - view controller unresponsive

I have an NSOperation subclass that does some heavy calculations. 我有一个NSOperation子类,它需要进行大量计算。 It has a delegate as well. 它也有一个代表。

If the user does not provide correct input, I validate it in the main method and through performSelectorOnMainThread I create and show an alert (from my NSOperation subclass) and then I call the delegate method as such: 如果用户没有提供正确的输入,那么我将在main方法中验证它,并通过performSelectorOnMainThread创建并显示警报(来自NSOperation子类),然后按如下方式调用委托方法:

    -(void) main{
    [self performSelectorOnMainThread:@selector(showAnAlert)
                                       withObject:nil
                                    waitUntilDone:YES];
                [self cancel]; //I need to cancel the operation
                return; //don't want to finish main running.

    }

- (void) showAnAlert{
   //Create an alert here
   [alert show];
}

And in my VC I have this: 

- (void) aDelegateMethodFromMyOperation{
   [self.textField setEndEditing:YES];
}

Now the problem is, once I dismiss the alert, I can't input any text in my textField.... It will show the keyboard on tap... but it won't accept my input... why is that? 现在的问题是,一旦我消除了警报,就无法在textField中输入任何文本。...它将在点击时显示键盘...但是它不接受我的输入...为什么?

Perhaps try: 也许尝试:

[textField becomeFirstResponder];

Because you're switching through multiple UI elements in the NSOperation , it is possible that full control is not being regained by the text field. 由于您正在NSOperation切换多个UI元素,因此文本字段可能无法重新获得完全控制权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM