【发布时间】:2016-01-02 22:59:23
【问题描述】:
我正在尝试检测 UISegmentedControl 选择是否更改为执行操作,但是当我更改选择时没有任何反应,我从单元格中的标签获得 UISegmentedControl
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UISegmentedControl *doing = (UISegmentedControl *)[cell viewWithTag:512];
NSString *done = [NSString stringWithFormat:@"%@", [[_myarraytask objectAtIndex:indexPath.row]valueForKey:@"done"]];
if ([done isEqualToString:@"NO"]) {
doing.userInteractionEnabled = YES;
if(doing.selectedSegmentIndex==0){
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Task finish ?" message:@"Please confirm" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self closeAlertview:(cell)];
}]];
dispatch_async(dispatch_get_main_queue(), ^ {
[self presentViewController:alertController animated:YES completion:nil];
});
}
}
}
【问题讨论】:
标签: ios uitableview uisegmentedcontrol didselectrowatindexpath