繁体   English   中英

无法从UITableViewCell调用performSegueWithIdentifier

[英]Cannot call performSegueWithIdentifier from a UITableViewCell

我无法解决此问题。 我已经通过情节提要声明了segue,并且试图从我编写的用于处理动态原型的自定义TableViewCell调用它。

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

我收到No visible @interface for 'PhotoChoiceTableViewCell' declares the selector 'performSegueWithIdentifier:sender:'No visible @interface for 'PhotoChoiceTableViewCell' declares the selector 'performSegueWithIdentifier:sender:'错误。

我想我已经确定我需要从UIView调用segue,但是我不知道如何实现适当的委托或协议来执行此操作。

我的UITableViewController称为InboxViewController,我的UITableViewCell称为PhotoChoiceTableViewCell。

谢谢!

在视图控制器上调用performSegueWithIdentifier 单元不实现此方法。

步骤1.实施协议。

@class MyCell;
@protocol MyDelegate <NSObject>

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

@end


@interface MyCell : UITableViewCell

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

@end

第2步。

Call a delegate in your cell:

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

在配置单元格时,请记住将视图控制器设置为委托。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM