关于UIMenuController的一个小示例-创新互联
今天天气好热 一整天都是晕的 oh mygod
公司主营业务:成都网站建设、网站制作、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联推出六枝免费做网站回馈大家。//
// PLViewController.m
// MenuView
//
// Created by apple-zql on 13-4-18.
// Copyright (c) 2013年 apple-zql. All rights reserved.
//
#import "PLViewController.h"
@interface PLViewController ()
@end
@implementation PLViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIButton *myBtn = [[UIButton alloc] init];
myBtn.frame = CGRectMake(100, 100, 100, 20);
[myBtn setTitle:@"你好" forState:UIControlStateNormal];
myBtn.backgroundColor = [UIColor blackColor];
[myBtn addTarget:self action:@selector(showMenu:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:myBtn];
[myBtn release];
}
- (void) showMenu:(id)sender
{
[self becomeFirstResponder];
UIMenuController *menu = [UIMenuController sharedMenuController];
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:@"1111" action:@selector(click:)];
UIMenuItem *item2 = [[UIMenuItem alloc] initWithTitle:@"2222" action:@selector(click1:)];
menu.menuItems = [NSArray arrayWithObjects:item1,item2, nil];
[menu setTargetRect:CGRectMake(10, 10, 30, 30) inView:self.view];
[menu setMenuVisible:YES animated:YES];
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(click:)) {
return YES;//显示
}else if(action == @selector(click1:)){
return YES;
}
return NO;//不显示
}
- (void) click1:(id)sender{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"1111" message:@"1111" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
- (void) click:(id)sender{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"2222" message:@"2222" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
- (BOOL)canBecomeFirstResponder{
return YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章题目:关于UIMenuController的一个小示例-创新互联
文章出自:http://pwwzsj.com/article/diepgp.html