Ahad Porkar
Ahad Porkar

Reputation: 1708

IBAction Not getting called after upgrade to (SDK 8.1 , Xcode 6)

Im using IBAction to set action for my buttons.

The buttons are in uitableview Cell.

this is my code :

-(IBAction)buttonAcceptClick:(id)sender
{
    UIButton *btn = (UIButton *) sender;
    UITableViewCell *cell;
    if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)]) {
         cell = (UITableViewCell*)btn.superview.superview;
          NSLog(@"sdk 8.1");

    } else {
         cell = (UITableViewCell*)btn.superview.superview.superview;
        NSLog(@"sdk 7.1");
    }
    NSLog(@"buttonAcceptClick");

2nd button is exactly like first one with different name.

now problem is everything works well in Xcode 5 and SDK 7.1 , but after i opened my project

in Xcode 6 and SDK 8.1 the program runs well on iPhone 4,5,6 simulator (sdks 7.1 and 8.1) ,

but not working on real device. and fun part is one of buttons working and not the other

one.

Upvotes: 1

Views: 128

Answers (1)

SefTarbell
SefTarbell

Reputation: 342

As I stated in my comment, there are better (more reliable) ways to get the the UITableViewCell. Here is one:

- (IBAction)someButtonTapped:(id)sender
{
    CGPoint point = [sender convertPoint:CGPointZero toView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

    // do something with the cell...
}

Upvotes: 2

Related Questions