UINavigationController
에 UITableViewController
을 루트 컨트롤러로 사용하고 있습니다. UINavigationController
은 UIPopoverController
안에 있습니다. UITableViewController
은 도청시 UITableView
을로드하는 UITableViewCell
(UISwitch
) 및 UITableViewCell
(UITableViewCellAccessoryDisclosureIndicator
)을 포함합니다.UITableViewCell의 UISwitch
내 문제는 UISwitch
으로 스 와이프 한 다음 다른 셀을 탭하면 didSelectRowAtIndexPath
이 호출되지 않는다는 것입니다. 다시 탭하면 다시 호출됩니다. 스 와이프하는 대신 UISwitch
번을 터치해도 아무런 문제가 없습니다.
문제는 iOS4에서만 발생합니다. iOS5에서 잘 작동합니다!
- (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 방법은 다음과 같습니다 :
내 cellForRowAtIndexPath 방법은
- (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];
}
그것은 매우 어려운 문제이고 그래서 당신의 도움이 필요 !
감사합니다.
* cellForRowAtIndexPath : * 및 * didSelectRowAtIndexPath에 대한 코드를 제공 할 수 있습니까? *? 두 개의 셀을 만드는 데 두 개의 다른 식별자를 사용하고 있습니까? (* CellIdentifier1 * 참조)? –
내 질문을 편집했습니다. – Giorgio
스 와이프하여 * UISwicth *를 탭하는 것이 무엇을 의미합니까? 내게는 선택 가능한 셀을 선택하는 데 아무런 차이가 없다. –