0

我无法从文本视图中调用 touchesBegan。它在一个虚拟项目中对我来说工作得很好,我只有一个视图,里面有一个 TextView。当我尝试在真正的项目中做到这一点时,具有如下层次结构:(我觉得这里有一些问题)

view (parent)
 scrollview(subview)
   view (grandSubview
     textview. 

代表没有被调用。.h 文件

@interface ActionViewController : UIViewController<UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *actionTakenTextView;

.m 文件

- (void)viewDidLoad
{
    [super viewDidLoad];
    actionTakenTextView.delegate=self; //actiontakentextview is the text view i am using.
    actionTakenTextView.layer.borderWidth=1;
    actionTakenTextView.layer.borderColor=[[UIColor grayColor] CGColor];
    // Below property is to set rounded corner of text view.
    actionTakenTextView.layer.cornerRadius=5.0;
    actionTakenTextView.clipsToBounds=YES;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"touchesBegan:withEvent:");
    [self.view endEditing:YES];
    [super touchesBegan:touches withEvent:event];
}

我觉得我在这里遗漏了一些非常小的东西。请帮忙。谢谢你。

4

0 回答 0