2013-02-21 24 views
4

我有一個接受登錄憑證的表格視圖。我想讓我的應用在加載或出現時自動選擇第一個tableview文本框。我希望將光標放置在「電子郵件地址」字段中並使鍵盤自動升起。我似乎無法弄清楚這一點。有人有主意嗎?謝謝!自動選擇第一個UITableView文本框

enter image description here

+0

使用此'[emailTextField becomeFirstResponder]' – HRM 2013-02-21 10:32:23

+0

我建議你必須具有靜態表視圖,你可以有IBOutlets到文本框,並使其在視圖中沒有加載或查看並出現第一個響應者。 – Raj 2013-02-21 10:35:35

回答

6

你必須將第一個響應者到UITextView ...

例如:

[textField becomeFirstResponder] 

您可以在UIViewController中的viewDidAppear做到這一點。

2
- (void)viewDidAppear:(BOOL)animated { 
[super viewDidAppear:animated]; 

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; 
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 

myTextField = (UITextField *)[cell viewWithTag:kMyTextFieldTag]; 
[myTextField becomeFirstResponder]; 
} 
相關問題