UITableViewCell indexPath crash in iOS7

后端 未结 6 2045
不知归路
不知归路 2020-12-06 07:38

I\'ve a UITableViewCell in a UITableViewController. In my cell there is a button that when you click takes you to another view with a

6条回答
  •  忘掉有多难
    2020-12-06 08:13

    I had similar problem where I had to find the textFileds value from TableView

    if ([Util isiOSVerGreaterThen7]) { // iOS 7
                UIView *contentView = (UIView *)[textField superview];
                UITableViewCell *cell = (UITableViewCell *)[contentView superview];
                UITableView *tableView = (UITableView *)cell.superview.superview;
                NSIndexPath *indexPath = [tableView indexPathForCell:cell];
    
                NSInteger sectionOfTheCell = [indexPath section];
                NSInteger rowOfTheCell = [indexPath row];
            }
            else { // iOS 6
                UITableViewCell *cell = (UITableViewCell *)[textField superview];
                UITableView *table = (UITableView *)[cell superview];
                NSIndexPath *pathOfTheCell = [table indexPathForCell:cell];
                NSInteger sectionOfTheCell = [pathOfTheCell section];
                NSInteger rowOfTheCell = [pathOfTheCell row];
            }
    

    And Util is

    + (BOOL)isiOSVerGreaterThen7 {
        if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
            return NO;
        } else {
            return YES;
        }
    }
    

提交回复
热议问题