【问题标题】:UIAlertView shown in NSOperation - view controller unresponsiveNSOperation 中显示的 UIAlertView - 视图控制器无响应
【发布时间】:2013-04-23 00:24:21
【问题描述】:

我有一个 NSOperation 子类,它进行了一些繁重的计算。它也有一个代表。

如果用户没有提供正确的输入,我会在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];
}

现在的问题是,一旦我解除警报,我就无法在我的 textField 中输入任何文本......它会在点击时显示键盘......但它不会接受我的输入......为什么就是它?

【问题讨论】:

    标签: iphone ios objective-c nsoperation


    【解决方案1】:

    或许可以试试:

    [textField becomeFirstResponder];
    

    由于您在 NSOperation 中切换多个 UI 元素,因此文本字段可能无法重新获得完全控制。

    【讨论】:

    • 谢谢,但我现在不希望文本字段成为响应者。
    • 好的。以防万一,我建议您测试这种方法只是为了笑。这可能是您的错误来源。
    • 刚刚尝试过,不幸的是结果相同:(如果我从操作队列中删除位 [aler show]; 一切正常.... :s
    • 啊发现问题了!我有两个嵌套的 performSelectorOnMainThread!不过谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多