0

I am having trouble resolving this issue. I have declared a segue via the storyboard and I'm trying to call it from a custom TableViewCell I wrote to handle the dynamic prototype.

- (IBAction)clickedPhoto:(id)sender {
[self performSegueWithIdentifier:@"PhotoDetail" sender:self];
}

I'm getting a No visible @interface for 'PhotoChoiceTableViewCell' declares the selector 'performSegueWithIdentifier:sender:' error.

I think I've figured out that I need to call the segue from a UIView but I can't figure out how to implement the proper delegate or protocol to do this.

My UITableViewController is called InboxViewController and my UITableViewCell is called PhotoChoiceTableViewCell.

Thank you!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
cherrycow
  • 83
  • 1
  • 9

1 Answers1

0

Call the performSegueWithIdentifier on your view controller. The cell does not implement this method.

Step 1. Implement a protocol.

@class MyCell;
@protocol MyDelegate <NSObject>

- (void)photoTappedInCell:(MyCell *)cell;

@end


@interface MyCell : UITableViewCell

@property (nonatomic, weak) id<TRUProductImageGalleryCellDelegate> delegate;

@end

Step 2.

Call a delegate in your cell:

- (IBAction)deleteButtonTapped:(id)sender
{
    if ([_delegate respondsToSelector:@selector(photoTappedInCell:)])
    {
        [_delegate performSelector:@selector(photoTappedInCell:) withObject:self];
    }
}

And remenber to set your view controller as a delegate when you're configuring the cell.

Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143
  • Thank you. I'm currently trying to educate myself on protocols. Do I do Step 1 in my UITableView .h or my UITableViewCell .h? – cherrycow May 17 '14 at 22:45
  • Sorry, I figured out my first question. Now I implement the call to the segue from the UITableView? – cherrycow May 17 '14 at 23:10
  • @cherrycow you have table view controller to control your views. That's where you should put all your logic and segues. – pronebird May 18 '14 at 00:52
  • This answer combined with [this other answer](http://stackoverflow.com/questions/17103400/is-it-possible-to-segue-from-a-uitableviewcell-on-a-uiview-to-another-view) got me to a working solution. – cherrycow May 19 '14 at 04:51