我在这里做错了,但我无法弄清楚它是什么。
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : NSObject <UIApplicationDelegate, UIScrollViewDelegate> {
UIWindow *window;
UIScrollView *scrollView;
UIPageControl *pageControl;
NSMutableArray *viewControllers;
UIView *flipside;
// To be used when scrolls originate from the UIPageControl
BOOL pageControlUsed;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;
@property (nonatomic, retain) IBOutlet UIPageControl *pageControl;
@property (nonatomic, retain) IBOutlet UIView *flipside;
@property (nonatomic, retain) NSMutableArray *viewControllers;
- (IBAction)showInfo:(id)sender;
- (IBAction)changePage:(id)sender;
@end
AppDelegate.m
- (IBAction)showInfo:(id)sender {
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
这是我得到的地方: 警告:类'AppDelegate'未实现'FlipsideViewControllerDelegate'协议。
后行: controller.delegate = self;
我的FlipsideViewController.h如下所示:
#import <UIKit/UIKit.h>
@protocol FlipsideViewControllerDelegate;
@interface FlipsideViewController : UIViewController {
id <FlipsideViewControllerDelegate> delegate;
}
@property (nonatomic, assign) id <FlipsideViewControllerDelegate> delegate;
- (IBAction)done:(id)sender;
@end
@protocol FlipsideViewControllerDelegate
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller;
@en
非常感谢任何帮助:)
答案 0 :(得分:4)
这正是错误消息所说的内容。 AppDelegate
只是没有实现协议。在您的标头文件中,在方括号(即FlipsideViewControllerDelegate
)之间添加<UIApplicationDelegate, UIScrollViewDelegate, FlipsideViewControllerDelegate>
,并实施-flipsideViewControllerDidFinish:
方法。
答案 1 :(得分:0)
尝试将FlipsideViewControllerDelegate添加到appDelegate
@interface AppDelegate : NSObject <UIApplicationDelegate, UIScrollViewDelegate,FlipsideViewControllerDelegate> {
UIWindow *window;
UIScrollView *scrollView;
UIPageControl *pageControl;
NSMutableArray *viewControllers;
UIView *flipside;
// To be used when scrolls originate from the UIPageControl
BOOL pageControlUsed;
}