我尝试在我的代码中使用AwesomeMenu,这是在这里: https://github.com/levey/AwesomeMenu
它的用法非常简单,如github页面中所列。我按原样跟着它。但菜单没有出现在UI中。我使用iOS 5.0和Xcode 4.2,使用iOS模拟器进行测试。
这就是我所做的:
我的ViewController.h中的
...
#import "AwesomeMenu.h"
#import "AwesomeMenuItem.h"
...
// I included the AwesomeMenuDelegate here
@interface com_FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource,AwesomeMenuDelegate> {
...
}
@property (nonatomic, retain) IBOutlet AwesomeMenu *awesomeMenu;
...
在故事板中 我创建了一个UIView实例,定位&amp;将其调整到我想要的位置,将其类更改为“AwesomeMenu”,并将其“引用插座”链接到IBOutlet属性“awesomeMenu”。
在ViewController.m
中...
@synthesize awesomeMenu;
...
AwesomeMenuItem *starMenuItem1;
AwesomeMenuItem *starMenuItem2;
...
...
// This method seems to be getting called, as I see the log messages
-(void) initializeSpringMenu {
NSLog(@"InitializeSpringMenu: entered");
UIImage *storyMenuItemImage = [UIImage imageNamed:@"GooglePlus.png"];
UIImage *storyMenuItemImagePressed = [UIImage imageNamed:@"GooglePlus.png"];
UIImage *starImage = [UIImage imageNamed:@"Mail-icon.png"];
starMenuItem1 = [[AwesomeMenuItem alloc]
initWithImage:storyMenuItemImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedContentImage:nil];
starMenuItem2 = [[AwesomeMenuItem alloc]
initWithImage:storyMenuItemImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedContentImage:nil];
// Now, setup the menu and the options
awesomeMenu = [[AwesomeMenu alloc]
initWithFrame:self.view.bounds
menus:[NSArray arrayWithObjects:starMenuItem1, starMenuItem2, nil]];
awesomeMenu.delegate = self;
NSLog(@"initializeSpringMenu: Done initializing it");
}
- (void)viewDidLoad {
...
[self initializeSpringMenu];
...
}
我觉得这很简单&amp;我不知道这里缺少什么。在进行AwesomeMenu的'init'时是否有界限?有人可以帮忙吗?运行应用程序时,UI中的视图显示为空白。
答案 0 :(得分:1)
- 琼,
您需要将AwesomeMenu
添加到ViewController的视图中。修改initializeSpringMenu
的结尾,如下所示:
.......
// Now, setup the menu and the options
awesomeMenu = [[AwesomeMenu alloc]
initWithFrame:self.view.bounds
menus:[NSArray arrayWithObjects:starMenuItem1, starMenuItem2, nil]];
awesomeMenu.delegate = self;
[self.view addSubView:awesomeMenu] // <-- THIS ADDS THE AWESOME VIEW TO YOUR VIEWCONTROLLERS VIEW
NSLog(@"initializeSpringMenu: Done initializing it");
}
应该是全部。