【问题标题】:textViewShouldBeginEditing is called twice in iOS7textViewShouldBeginEditing 在 iOS7 中被调用两次
【发布时间】:2013-12-03 07:42:29
【问题描述】:

我正在使用具有 iOS 7.0 的 Xcode 5.0.2 和 iPhone 5,其中 textViewShouldBeginEditing 被调用了两次。

有没有办法让textViewShouldBeginEditing方法被调用一次?

这是我的代码:

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
    [textView resignFirstResponder];
    if (mIsEditing == NO)
    {
        [textView resignFirstResponder];
        mIsEditing = YES;
       [mDelegate updateViewForEditMode: YES : textView];
    }
    return NO;
}

【问题讨论】:

  • 使用一个标志,在每次调用这个代理时设置为是/否。只有在“是”时才进行处理。
  • 我已经使用了一个标志'mIsEditing'。理想情况下,它应该只被调用一次。

标签: ios objective-c ios7 uitextfield xcode5


【解决方案1】:

试试这个可能对你有帮助

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{

    if (textView==urtxtviewname) {

     //   do yur coding

    }
    else (textView ==urtxtviewname)

    {
      // do your coding

    } 
    return YES;

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-24
    • 2021-04-09
    相关资源
    最近更新 更多