那麼,如果你正在做的設置,那麼我建議把他們在正確的位置,並使用設置。束。
我猜你是在做設置,雖然這對你的應用程序非常重要,如果他們不得不從應用程序跳轉到設置並返回,這將是一個可怕的用戶體驗。
當你說這個任務很重要 - 你能否詳細說明 - 就像我所做的一樣,它並不重。
使用一個UITableViewController
爲您想把使用的代碼類似於每個單元:
cell.textLabel.text = @"Last name:";
UIFont *labelFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];
CGSize textSize = [cell.textLabel.text sizeWithFont:labelFont];
baseRect.origin.x = textSize.width+15;
baseRect.origin.y +=7;
baseRect.size.width = baseRect.size.width - textSize.width - 15;
baseRect.size.height = 23;
UITextField *textField = [[UITextField alloc] initWithFrame:baseRect];
textField.keyboardType = UIKeyboardTypeAlphabet;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.delegate = self;
textField.placeholder = @"last name";
[textField addTarget:self action:@selector(lastNameChanged:) forControlEvents:UIControlEventAllEditingEvents];
textField.tag = 182;
[cell.contentView addSubview:textField];
[textField release];
這爲我工作重現您所談論的接口 - 這裏的例子是一個TextField - 但是相同的代碼在所有控件上都運行得很好。
是不是重複使用你的UITableViewCells?如果你確實如何區分哪個文本域調用了lastNameChanged:? – 2009-06-26 13:53:19
當然,我是! - textField上的標籤告訴我哪個字段是哪個字段。此外,我確信任何與我的標籤列表匹配的控件都會在回收單元時被刪除。 – Grouchal 2009-06-26 15:43:37