I'm getting the UITableViewCell a UIButton belongs to like this:
-(void)buttonHandler:(UIButton *)button {
OrderCell *cell = [[button superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
And it works fine in anything before iOS 7. But gives me:
[UITableViewCellScrollView item]: unrecognized selector sent to instance 0x17ae2cf0
if I run the app in iOS 7. BUT if I do:
-(void)buttonHandler:(UIButton *)button {
OrderCell *cell = [[[button superview] superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
Then it works in iOS 7 but not earlier?!?!?!
I'm circumventing the issue by doing this:
OrderCell *cell;
if([[[UIDevice currentDevice] systemVersion] isEqualToString:@"7.0"])
cell = [[[button superview] superview] superview];
else
cell = [[button superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
but WTF is going on!? Does anyone know why this happens?
Thanks!
UITableViewCell. Obviously that structure has changed in iOS 7. There are much safer ways to do what you want. And your new code will break under iOS 7.1 and iOS 8. - rmaddy