我有一個自定義tableview 6行。 5行中有UITextFields,1行中有UISwitch。UITableViewCell與UISwitch導致.tag = 1成爲空
我添加文本框是這樣的:
switch (indexPath.row) {
case 0:
txtLabel.text = NSLocalizedString(@"Name:", @"");
txtField.tag=1;
[txtField becomeFirstResponder];
[cell.contentView addSubview:txtField];
[txtField release];
break;
在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
開關被添加等:
case 3:
txtLabel.text = NSLocalizedString(@"Male:", @"");
UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
cell.accessoryView = mySwitch;
[mySwitch setTag:6];
break;
我讀在另一個方法的值,如:
UITextField *daName = (UITextField *)[self.view viewWithTag:1];
但由於某種原因,只要添加UISwitch,daName值就會變爲null。其他值是讀得很好(所以標籤2是好的,標籤3是好的等)
我在這裏錯過了什麼?因爲當我刪除UISwitch然後我從標記1得到一個值...
在此先感謝!
編輯
我只是看到,只要我有我的tableview 6行與標籤ID爲1的元素獲得空......只要我有5行,我能得到的所有值。 ..
一次顯示多少行,甚至是部分顯示? – zaph 2011-03-10 23:47:20
該表現在有6行,其中5個帶有標籤和UITextView,1個帶有標籤和UISwitch。他們一次顯示 – CyberK 2011-03-11 07:23:26