2010-06-10 63 views
1

我在UITableViewCell中有一個UITextField。無論我嘗試什麼,它都不會在iPad上激活(但它在iPhone上運行正常)。點擊它並告訴它成爲第一個響應者都失敗了。奇怪的是,如果我採用完全相同的代碼並將其移到另一個視圖控制器中,它會執行得很好。這使得它看起來好像在父UITableViewController中可能存在問題,但我找不到任何明顯的問題。我希望在那裏有人遇到過類似的問題,並能指引我朝着正確的方向前進。UITableViewCell裏面的UITextField不會在iPad上激活,但可以在iPhone上工作

下面是示例代碼,當我把它移動到一個新的項目或把它放在我的應用程序委託立即推出了一個新的視圖控制器工作正常:

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
} 

if (indexPath.row == 0) { 
    UITextField *nameText = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, cell.contentView.frame.size.width, cell.contentView.frame.size.height)]; 
    nameText.delegate = self; 
    nameText.backgroundColor = [UIColor redColor]; 

    [cell.contentView addSubview:nameText]; 

    [nameText becomeFirstResponder]; 
    [nameText release]; 

} 

// Configure the cell... 

return cell; 
} 

幫助!

回答

0

就我而言,如果我問這個問題,我會在幾分鐘後找到答案。事實證明,我之前有幾個步驟要求第一響應者,但沒有辭職。活到老,學到老!

相關問題