我的視圖控制器變得越來越複雜,所以我決定將一些控件分組在一起,並劃分子視圖。在我的視圖控制器中,我抓住了視圖:UIVIEW子類與UITextViewDelegate
@property (strong, nonatomic) PostMenuCell *menuCell;
menuCell = [[PostMenuCell alloc] initWithFrame:CGRectMake(3,200,304,96) ];
menuCell.textView.delegate = self;
[self.view addSubview:menuCell];
它看起來很好。我有一個文本視圖和現在用的是委託在VC像這樣:
@interface PostPictureViewController : UIViewController <UITextViewDelegate>
我試圖使用文本視圖委託方法如:
- (void)textViewDidBeginEditing:(UITextView *)textView
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
鍵盤彈出時你單擊文本區域,但委託方法不會被使用,所以我不能執行任何操作或關閉鍵盤。我以爲menuCell.textView.delegate = self;會使文本視圖代表VC,但顯然不是。
任何指導將不勝感激。
@shabzco該建議沒有意義。 –