У меня есть UINavigationController
с UITableViewController
в качестве корневого контроллера.UINavigationController
находится внутри UIPopoverController
.UITableViewController
содержит UITableViewCell
(с UISwitch
) и UITableViewCell
(с UITableViewCellAccessoryDisclosureIndicator
), которые загружают еще один UITableView
при касании.
Моя проблема в том, что при смахивании UISwitch
и затем коснитесь другой ячейки, didSelectRowAtIndexPath
не вызывается.Если я нажму снова называется.Если я коснусь UISwitch
, вместо того, чтобы провести, нет никаких проблем.
Проблема только на iOS4.На iOS5 отлично работает!
Мой метод cellForRowAtIndexPath:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier1 = @"Cell1";
static NSString *CellIdentifier2 = @"Cell2";
// Configure the cell...
NSUInteger row = [indexPath row];
UITableViewCell *cell = nil;
switch (row) {
case 0: {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = [controllers objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryNone;
UITextField *passwordTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 11, 400, 30)];
passwordTextField.adjustsFontSizeToFitWidth = YES;
passwordTextField.placeholder = @"Richiesta";
passwordTextField.keyboardType = UIKeyboardTypeDefault;
passwordTextField.secureTextEntry = YES;
passwordTextField.tag = 100;
[passwordTextField addTarget:self action:@selector(passwordChanged:) forControlEvents:UIControlEventEditingChanged];
passwordTextField.text = password;
[cell addSubview:passwordTextField];
[passwordTextField release];
break;
}
case 1: {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = [controllers objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryNone;
UITextField *pinTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 11, 400, 30)];
pinTextField.adjustsFontSizeToFitWidth = YES;
pinTextField.placeholder = @"Richiesta";
pinTextField.keyboardType = UIKeyboardTypeDefault;
pinTextField.secureTextEntry = YES;
pinTextField.tag = 101;
[pinTextField addTarget:self action:@selector(pinChanged:) forControlEvents:UIControlEventEditingChanged];
pinTextField.text = aspin;
[cell addSubview:pinTextField];
[pinTextField release];
break;
}
case 2: {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier2] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
UITableViewController *controller = [controllers objectAtIndex:row];
cell.textLabel.text = controller.title;
cell.detailTextLabel.text = @"Busta Crittografica P7M (CAdES)";
envelopeType = cell.detailTextLabel.text;
break;
}
case 3: {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
}
cell.textLabel.text = @"Dichiaro di aver preso visione del documento, di sottoscriverne il contenuto e di essere consapevole della validità legale della firma apposta";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.numberOfLines = 5;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
//add a switch
UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero];
[switchview addTarget:self action:@selector(declarationChanged:) forControlEvents:UIControlEventValueChanged];
switchview.on = declaration;
cell.accessoryView = switchview;
[switchview release];
break;
}
}
return cell;
}
А мой метод didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
switch (row) {
case 0: {
[[[tableView cellForRowAtIndexPath:indexPath] viewWithTag:100] becomeFirstResponder];
break;
}
case 1: {
[[[tableView cellForRowAtIndexPath:indexPath] viewWithTag:101] becomeFirstResponder];
break;
}
case 2: {
((CheckListController *)[self.controllers objectAtIndex:2]).contentSizeForViewInPopover = self.view.bounds.size;
self.contentSizeForViewInPopover = self.view.bounds.size;
[self.navigationController pushViewController:[self.controllers objectAtIndex:2]
animated:YES];
break;
}
default:
break;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Это очень сложная проблема, поэтому мне нужна ваша помощь!
Спасибо.