IOS AMSlideMenu打开菜单回调 [英] IOS AMSlideMenu open menu callback

查看:221
本文介绍了IOS AMSlideMenu打开菜单回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IOS中是新的,不能理解有关代理和协议的一些事情。
在我的项目中,我使用 AMSlideMenu 进行幻灯片菜单。我需要在幻灯片菜单中更新相同的数据。为此,我需要捕获openMenu回调。在幻灯片菜单的说明中,我发现这个

 如果要获取菜单的打开/关闭回调,则设置MainVC的委托属性,实现名为AMSlideMenuProtocols的协议。 

@optional
- (void)leftMenuWillOpen;
- (void)leftMenuDidOpen;
- (void)rightMenuWillOpen;
- (void)rightMenuDidOpen;

我试图用此代码捕捉回调

  // myClass.h 
#importAMSlideMenuLeftTableViewController.h
#importAMSlideMenuMainViewController.h
@interface myClass:AMSlideMenuLeftTableViewController&AMSlideMenuDelegate>

@end

//myClass.m
#importmyClass.h

@interface myClass()

@end

@implementation myClass
- (void)leftMenuWillOpen
{
// something
}
@end

leftMenuWillOpen 永远不会被调用。我做错了什么?

解决方案

我想你没有将代理设置为幻灯片菜单。 myClass的对象应该是AMSlideMenu对象的代理。


I'm new in IOS, and can't understand some things about delegates and protocols. In my project I'm using AMSlideMenu for slide menu. I need to update same data in slide menu. For that I need to catch openMenu callback. In instruction for slide menu I found this

 If you want to get menu's open/close callbacks, then set MainVC's delegate property, and implement protocol named 'AMSlideMenuProtocols'. 

 @optional
 - (void)leftMenuWillOpen;
 - (void)leftMenuDidOpen;
 - (void)rightMenuWillOpen;
 - (void)rightMenuDidOpen;

I tried to catch callback with this code

//myClass.h    
#import "AMSlideMenuLeftTableViewController.h"
#import "AMSlideMenuMainViewController.h"
@interface myClass : AMSlideMenuLeftTableViewController<AMSlideMenuDelegate>

@end

//myClass.m
#import "myClass.h"

@interface myClass ()

@end

@implementation myClass
-(void)leftMenuWillOpen
{
    //something
}
@end

but leftMenuWillOpen never gets invoked. What I did wrong?

解决方案

I guess you are not setting the delegate to the slide menu. The object of myClass should be the delegate to AMSlideMenu object.

这篇关于IOS AMSlideMenu打开菜单回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆