将Delegate设置为self PaperFoldMenuController

时间:2013-02-03 02:12:17

标签: ios objective-c

我正在努力让这个PaperFoldMenuController继续进行,虽然它运行正常,但在设置foldMenuViewController.delegate = selfAssigning to 'id<PaperFoldMenuControllerDelegate>' from incompatible type 'DOAppDelgate *const__strong'时收到错误。我将它分配到与演示完全相同的位置,似乎运行正常。有什么想法吗?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
  [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

  UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
  DOMasterViewController *controller = (DOMasterViewController *)navigationController.topViewController;
  controller.managedObjectContext = [self managedObjectContext];

  foldMenuViewController = [[DOMenuViewController alloc] initWithMenuWidth:200 numberOfFolds:5];
  foldMenuViewController.delegate = self;
  [self.window setRootViewController:foldMenuViewController];

  NSMutableArray* viewControllers = [NSMutableArray array];
  [viewControllers addObject:navigationController];
  [viewControllers addObject:controller];

  [foldMenuViewController setViewControllers:viewControllers];

  return YES;
}

1 个答案:

答案 0 :(得分:1)

您可能需要您的班级来实施协议:PaperFoldMenuControllerDelegate

@interface DOAppDelgate()<PaperFoldMenuControllerDelegate>
- (BOOL)paperFoldMenuController:(PaperFoldMenuController *)paperFoldMenuController shouldSelectViewController:(UIViewController *)viewController;
- (BOOL)paperFoldMenuController:(PaperFoldMenuController *)paperFoldMenuController shouldFoldMenuToRevealViewController:(UIViewController *)viewController;
- (void)paperFoldMenuController:(PaperFoldMenuController *)paperFoldMenuController didSelectViewController:(UIViewController *)viewController;
@end

...然后实施这些方法。

编辑:将实现更改为接口,mybad。