I'm hoping now apps for IOS 7 are being accepted by Apple we can talk about it?
I'm trying to fix my app so it works on IOS 7 and have made some very good progress this evening. I have two outstanding issues, but will post them separately. The first issue is this line (I added a log line after to debug it) ...
NSIndexPath *indexPath = [settingsTableView indexPathForCell:(UITableViewCell *)[sender superview]];
NSLog(@"Changed %@ <-**-> %@", [sender superview], indexPath );
The log shows ....
IOS7
2013-09-11 22:18:02.985 BusTimes[21013:a0b] Changed <UITableViewCellScrollView: 0xbfc1c80; frame = (0 0; 320 44); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0xbfc1e70>; layer = <CALayer: 0xbfc1540>; contentOffset: {0, 0}> <-**-> (null)
2013-09-11 22:18:08.577 BusTimes[21013:a0b] Changed <UITableViewCellScrollView: 0xbfc62d0; frame = (0 0; 320 44); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0xbfc64c0>; layer = <CALayer: 0xbfc5b90>; contentOffset: {0, 0}> <-**-> (null)
IOS 6
2013-09-11 22:25:34.495 BusTimes[2116:907] Changed <UITableViewCell: 0x20862f40; frame = (0 179; 320 44); text = 'Reminder Mins: 5'; autoresize = W; layer = <CALayer: 0x208523d0>> <-**-> <NSIndexPath 0x20861430> 2 indexes [0, 3]
2013-09-11 22:25:47.499 BusTimes[2116:907] Changed <UITableViewCell: 0x20865180; frame = (0 223; 320 44); text = 'AutoRefresh Secs: 60'; autoresize = W; layer = <CALayer: 0x20865340>> <-**-> <NSIndexPath 0x2085c0d0> 2 indexes [0, 4]
So on IOS 7 indexPath is always (null) and .section and .row are always 0. But this works fine on IOS 6 and returns .section 0 and row 3, and .row 4. Can anyone suggest how I might get IOS 7 to behave in the same way for me?
Many Thanks in advance.
Plasma
* SOLUTION - I changed my code to this following the comments *
UIView *view = sender;
while (![view isKindOfClass:[UITableViewCell class]]) {
view = [view superview];
}
NSIndexPath *indexPath = [settingsTableView indexPathForCell:(UITableViewCell *)view];
It's usually safer to make no assumptions about the view hierarchy of a cell. In the past, I've used a category with methods like this on UIView to find the superview which is a cell:
- (UIView*)ancestorOrSelfWithClass:(Class)cls {
if ([self isKindOfClass:cls]) {
return self;
} else if (self.superview) {
return [self.superview ancestorOrSelfWithClass:cls];
} else {
return nil;
}
}
So you'll ask for [sender ancestorOrSelfWithClass:[UITableViewCell class]]
to get the actual cell, and it'll work no matter what hierarchy exists within the cell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With