我的 FlipsideViewController 的“完成”按钮不起作用(没有崩溃,但也没有关闭视图)。这是代码:
在 FlipSideViewController.h
@class FlipsideViewController;
@protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller;
@end
@interface FlipsideViewController : UIViewController
@property (weak, nonatomic) id <FlipsideViewControllerDelegate> delegate;
- (IBAction)done:(id)sender;
@end
在 FlipSideViewController.m 中
- (IBAction)done:(id)sender
{
// an NSLog statement that is here is logging properly
[self.delegate flipsideViewControllerDidFinish:self];
}
在 MainViewController.h
@interface FifthViewController : UIViewController <FlipsideViewControllerDelegate>
...
在 MainViewController.m
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showAlternate"]) {
[[segue destinationViewController] setDelegate:self];
}
}
顺便说一句,这是一个选项卡式应用程序,所以我认为这可能与它有关。任何建议,将不胜感激。谢谢你。