簡體   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