L'action UISwitch ne fonctionne pas dans iOS 10

J'ai un button de commutation dans une cellule de la vue de la table. Auparavant dans iOS 9, tout fonctionne bien, après le clic sur le button passeront à la méthode d'action. Mais après la mise à jour vers iOS 10, la méthode d'action ne sera jamais appelée. Quelqu'un a un problème similaire à celui-ci?

cell.m

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSSsortingng *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code UIImageView *bgView = [[UIImageView alloc] initWithFrame:CGRectZero]; [bgView setImage:[[UIImage imageNamed:@"customcell.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]]; [self setBackgroundView:bgView]; UIImageView *selectedBgView = [[UIImageView alloc] initWithFrame:CGRectZero]; [selectedBgView setImage:[[UIImage imageNamed:@"cellselect.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)]]; [self setSelectedBackgroundView:selectedBgView]; nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 13, 250, 40)]; [nameLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleRightMargin]; [nameLabel setFont:[UIFont boldSystemFontOfSize:16]]; [nameLabel setBackgroundColor:[UIColor clearColor]]; [nameLabel setTextColor:[UIColor whiteColor]]; [nameLabel setNumberOfLines:0]; [self.contentView addSubview:nameLabel]; switchButton = [[UISwitch alloc] initWithFrame: CGRectMake(230, 17, 100, 30)]; [switchButton setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin]; [switchButton addTarget:self action:@selector(switchActivated:) forControlEvents:UIControlEventTouchUpInside]; [switchButton setHidden:YES]; [self.contentView addSubview:switchButton]; } return self; } 

Méthode d'action:

 - (void) switchActivated:(id)sender { if(switchButton.on) { [selectedItem setObject:@"YES" forKey:@"valueEntry"]; } else { [selectedItem setObject:@"NO" forKey:@"valueEntry"]; } } 

Cellule ViewController.m pour la ligne au path d'index:

 - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath UITableViewCell *tableViewCell = [aTableView dequeueReusableCellWithIdentifier:[NSSsortingng ssortingngWithFormat:@"homeReportCustomizationCell_%d",indexPath.row]]; if(!tableViewCell) { tableViewCell = [[Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[NSSsortingng ssortingngWithFormat:@"Cell_%d",indexPath.row]]; } ........... } 

Changez simplement UIControlEventTouchUpInside intérieur de [switchButton addTarget:self action:@selector(switchActivated:) forControlEvents:UIControlEventTouchUpInside];

Pour: UIControlEventValueChanged

J'ai le même problème!

J'ai un UISwitch et un UITextField dans un UIScrollView. J'ajoute le scrollView à mon self.view.

J'ai testé cela avec un iPad Pro sous iOS 10 – Avant de passer à la dernière version d'iOS, tout fonctionnait très bien. Maintenant, mes methods ne sont pas appelées !!

J'espère que je n'aurai pas à recourir à une solution programmatique – ce serait un peu dommage.