Josué H.
Josué H.

Reputation: 1191

Event clicked in UITableView

I have a problem when clicked a row in a UITableView

I used this method didSelectRowAtIndexPath to catch when the user clicks on a row, but doesn't work normally. the user must press and hold the row to execute the action but do not want it to be so.

Any idea what may be happening?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

   Refunds *current = [refunds_view objectAtIndex:indexPath.row];       

   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
   DetailRefundsViewController *myVC = (DetailRefundsViewController *)[storyboard     instantiateViewControllerWithIdentifier:@"DetailRefundsViewController"];
[self presentViewController:myVC animated:YES completion:nil];
 }

Thanks.

Best Regards.

Upvotes: 0

Views: 98

Answers (2)

Luvie
Luvie

Reputation: 126

In my case, your code is instantly work, just modify class name and Storyboard Identifier.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    LJWDetailViewController *myVC = (LJWDetailViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LJWDetailViewController"];
    [self presentViewController:myVC animated:YES completion:nil];
}

I think, some of your codes are block this didSelectRowAtIndexPath: Method.

find out which controls are block this method and set those control's delaysContentTouches Property by NO like this.

_imageScroll.delaysContentTouches = NO;

Sorry for Poor English :<

Upvotes: 1

Doug
Doug

Reputation: 106

If you're using StoryBoards, then I think you're better off using a push segue directly from the TableViewCell to the ViewController you want in the Interface Builder (control click and drag from the TableViewCell to the ViewController). Make sure to give the segue a name (in my case below "showDetail"). Then implement the code below:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        [[segue destinationViewController] setDetailItem:object];
    }    
}

Upvotes: 0

Related Questions