我正在尝试使用协议将数据与 segue 一起传回。我正在关注这个答案:如何在反转 Segue 时将信息传回 iOS?
所以我已经做了:
PageScrollViewController.h
@protocol MyDataDelegate <NSObject, UIPageViewControllerDelegate>
- (void)recieveData:(NSString *)theData;
@end
我还添加了属性:
@property (nonatomic,weak) id<MyDataDelegate> delegate;
ContainerViewController.h
#import "PageScrollViewController.h"
@interface ContainerViewController : UIViewController <MyDataDelegate>
//...
容器视图控制器.m
- (void)recieveData:(NSString *)theData {
//Do something with data here
}
在这里我被困住了:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//Get a handle on the view controller about be presented
PageScrollViewController *secondViewController = segue.destinationViewController;
if ([PageScrollViewController isKindOfClass:[PageScrollViewController class]]) {
PageScrollViewController.delegate = self;
}
}
该行 PageScrollViewController.delegate = self;
给出了一个错误:在“PageScrollViewController”类型的对象上找不到属性“委托”,但我确实将它添加为属性并合成了它......