私はメッセージベースのiPhoneアプリに取り組んでいます。受信したメッセージに返信する画面があります。この画面には、bottomTextView と topTextView のような 2 つの UITextView が含まれています。
topTextView は、bottomTextView の InputAccessory ビューとして追加されます。
ユーザーが画面に入ると、topTextView
FirstResponder になる必要があります。表示されていますが、カーソルがtopTextViewに配置されていません。カーソルは textview にありbottomTextView
ます。カーソルを配置してtopTextViewを最初の応答者にする方法は?
これが私が試したコードです:
- (void)viewDidLoad
{
[super viewDidLoad];
bottomBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 380, 320, 40)];
bottomBarViewImage.image = [UIImage imageNamed: @"toolbarbg~iphone.png"];
[bottomBarView addSubview: bottomBarViewImage];
[self.view addSubview: bottomBarView];
bottomTextView = [[UITextView alloc] initWithFrame:CGRectMake(35, 7.5, 210, 25)];
bottomTextView.delegate = self;
bottomTextView.backgroundColor = [UIColor clearColor];
bottomTextView.font = [UIFont fontWithName:@"Helvetica" size:14];
bottomTextView.scrollEnabled = NO;
[bottomBarView addSubview: bottomTextView];
topBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 380, 320, 40)];
topBarViewImage.image = [UIImage imageNamed: @"toolbarbg~iphone.png"];
[topBarView addSubview: topBarViewImage];
topTextView = [[UITextView alloc] initWithFrame:CGRectMake(35, 7.5, 210, 25)];
topTextView.delegate = self;
topTextView.backgroundColor = [UIColor clearColor];
topTextView.font = [UIFont fontWithName:@"Helvetica" size:14];
topTextView.scrollEnabled = NO;
[topBarView addSubview: topTextView];
[bottomTextView becomeFirstResponder];
[bottomTextView setInputAccessoryView: topBarView];
}
-(void) textViewDidBeginEditing:(UITextView *)textView
{
if(textView == bottomTextView)
{
bottomTextView.scrollEnabled = NO;
[topTextView becomeFirstResponder];
}
}
topTextView
withが表示されtopBarView
ていますが、カーソルが topTextView に配置されていません。この問題を解決するのを手伝ってくれませんか? 前もって感謝します。