ROM版本
HTC One/M7 802d
ROM作者
大盛
http://weibo.com/DaShengdd
Android版本
Android4.2.2
创建日期
2013.09.09
ROM大小
840M
MD5验证码
6F6D0A602044680E4062D2F5D6AE6ED5
适用机型
HTC One 电信版(国行)
QQ群
QQ: 177061373
ROM简介:
声明:该版本只针对HTC one国行电信版本,其他版本请勿刷!
该版本发布是在9月5号发布的电信版的毒蛇相关ROM:http://www.wanjiquan.com/thread-1877213-1-1.html的升级优化版本,该版本主要是针对有网友反应毒蛇版本ROM的信号有时候不稳定以及wifi容易断线的修复,修改超级用户的问题。准确的来说是再次加强信号和wifi的稳定,因为上一个版本至少我没有测试出来有关信号的点点问题,不会是人品问题吧(嘻嘻
开个玩笑)!该版本添加了很多网友喜欢的状态栏显示网络流量,更进一步巩固版本的稳定性。请放心使用!
再次重申:该版本是针对国行电信版本的HTC one其他版本请勿刷!该ROM不是完全汉化版本的ViperOne2.1.0ROM,但是功能完全不少,是考虑既要保证原工具的原滋原味,又要符合的用户习惯。更多的功能在这里不再赘述,更多的体验还得自己来体验。
功能介绍:
※ 国行电信HTC One稳定升级版
※ 增加状态栏网络流量显示
※ 修复和加固信号的稳定
※ 下拉通知栏传统农历显示
※ 最新ViperOne2.1.0毒蛇工具
※ 新版本的毒蛇侧边栏工具以及毒蛇市场
※ 个性的MIUI电量条以及更多色彩调整
※ 进一步优化刷机脚本
※ 内置天气显示开关
※ 采用最新版本国行内核
※ 修复桌面天气更新延迟的问题
※ 进一步优化系统UI更加稳定快捷
※ 加固侧向桌面工具的稳定流畅
※ 加入最新国内新闻源
※ 更新微博至最新版本
※ 添加最新短信亮屏开关
※ 默认加载全部快捷开关
※ 支持快捷开关的增删
※ 更多实体键短按和长按菜单
※ 添加HTC 小Hi助手
※ 添加高级设置菜单
※ 添加最新来去电归属地数据库文件
※ 内置去除海带条的显示开关
※ 添加状态栏的电池、时钟、图标自定义设置
※ 添加系统桌面4x2模式的时钟插件、天气插件
※ 添加音量上下键唤醒屏幕开关
※ 添加无线扫描间隔选项
※ 电源键选项开关
※ 自定义通知栏快捷开关的选项
更新内容:
更多更新内容如上所述...
同时期待您的反馈和建议,您可以跟帖反馈或者在大盛微博进行反馈和建议...
截图展示:
了解更多:点击打开链接
杂志app-UI配制篇
背景
现在公司有需求是关于杂志app,里面每个页面可能有不同的展现方式,不同的内容,不同的操作方式。那么这里就有一个需求就是根据用户定制这些不同的展现方式,不同的内容,不同的操作方式,在我们手机端就能正确的展示这些功能。如果一个应用app所有的UI都已经组件化,那么我只需要把这些组件组合拼装就行了,修改配制文件即可。友好的把配制文件的给服务端或者是产品组,让其很容易地修改配制文件。
应用场景
按照我们定义的XML规范进行,考虑到一些情况,除了一些有特殊需求的app,app之前有相似性,应用app的UI符合已有UI组件的要求,业务逻辑相同或相似,UI和业务逻辑分离。
实现原理
根据配制文件定义相关控件或组件,配制其属性。UI引擎解析配制文件,生成对应的控件或组件模型,在需要的时候添加到当前的VIew上。UI引擎大致分为如下几部分,
1.Builder生成器类,2.Element控件或者组件容器类,3.Controller控制器类,处理业务逻辑和UI,4View普通视图类,5.TableView视图类。
从两个方面来看。
第一方面,从程序运行流程来看。
1.当第一次程序运行起来之后,会用Element基类的扩展类RootElement(XMLBuilder),解析配制文件如XML。
2.Builder生成器类把XML里面的结点通过递归的方法,解析成相应的Element控件或组件容器。
3.最终会成一个树形结构在内存中,内存地址根据RootElement对象来取。
4.程序继续往下走,这时会创建一个Controller业务控制器类,这个Controller是从基础业务控制器继承下来。把RootElement的对象指针传给该Controller.
5.把业务控制器赋值给Window的rootViewController,同时让window可见。
6.让window可见时会加载View,系统回调业务控制类的loadView或者viewDidLoad来渲染UI.此时用视图类递归遍历RootElement,根据RootElement容器提供生成View的方法,生成相应的控件或者是组件,addSubView。此时UI渲染完成,呈现给用户了。
第二方面,从程序运行时来看。
我们知道message与方法的真正实现是在执行阶段绑定的,而非编译阶段。编译器会将消息发送转换成对objc_msgSend方法的调用。objc_msgSend(receiver, selector, arg1, arg2, …);
当用户点击设备屏幕时,IOS捕捉到一系列的触摸,将其打包到UIEvent对象中并放置到应用程序活动事件队列中。单例UIApplication对象管理应用程序,从事件队列中取出最前面的事件并将其分发以便处理。通常,其发送事件给应用程序的主窗口——即聚焦于用户交互的窗口——窗口对象代表窗口再发送事件给初始对象进行处理。
在iOS系统中有个很重要的概念:Responder。基本上所有的UI相关的控件,view和viewcontroller都是继承自UIResponder。事件的分发正是通过由控件树所构成的responder chain(响应链)所进行的。
例如一个简单的Button点击事件。
1.当button被按下的时候,系统接收这到个事件,事件经过传递,分发,最终在应用程序的交互窗口的初始控件对象处理。
2.在ButtonElement里监听到这个被按下的事件,先交给父类处理,然后处理自己的逻辑,。
3.依次在ButtonElement--LabelElement--RootElement--Element这个继承树上进行传递。
4.当传递到根结点时即Element,消息就开始分发,消息的分发是动态绑定的,编译器会将消息发送转换成对objc_msgSend方法的调用,objc_msgSend(receiver, selector, arg1, arg2, …);
5.最终消息会分发到指定的Controller里的方法里去执行。处理自己的业务逻辑。
广告时间:
新浪微博: messageloop亮仔
先看看这个图
要做的样子就是点击下面这个按钮,弹出上面这个带箭头的弹出框
下面来看看怎么搞
#import <UIKit/UIKit.h> @interface UIActionSheetDemoViewController : UIViewController<UIPopoverControllerDelegate> { UIPopoverController* _popover; } #import "UIActionSheetDemoViewController.h" #import "popController.h" @implementation UIActionSheetDemoViewController @synthesize popover = _popover; #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; UISegmentedControl* settingView = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"FootballCF",@"BasketballCF",nil]]; [settingView setSegmentedControlStyle:UISegmentedControlStyleBar]; [settingView setFrame:CGRectMake(500, 900, 160, 75)]; [settingView setNeedsLayout]; [settingView addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:settingView]; [settingView release]; } - (void)viewDidUnload { [super viewDidUnload]; if (self.popover != nil) { [self.popover release]; self.popover = nil; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } -(void)segmentAction:(UISegmentedControl*)seg{ //清除已经显示的弹出窗口 if (self.popover.popoverVisible) { [self.popover dismissPopoverAnimated:YES]; } //初始化待显示控制器 popController* controller = [[popController alloc] init]; //设置待显示控制器的范围 [controller.view setFrame:CGRectMake(550, 490, 350, 450)]; //设置待显示控制器视图的尺寸 controller.contentSizeForViewInPopover = CGSizeMake(350, 450); //初始化弹出窗口 UIPopoverController* pop = [[UIPopoverController alloc] initWithContentViewController:controller]; controller.popover = pop; self.popover = pop; self.popover.delegate = self; //设置弹出窗口尺寸 self.popover.popoverContentSize = CGSizeMake(350, 450); //显示,其中坐标为箭头的坐标以及尺寸 [self.popover presentPopoverFromRect:CGRectMake(550, 890, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO]; [controller release]; [pop release]; //[self.popover dismissPopoverAnimated:YES]; } -(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{ NSLog(@"popover dismiss"); } @end
#import <UIKit/UIKit.h> @interface popController : UIViewController<UIPickerViewDelegate,UIPickerViewDataSource> { UIPopoverController* _popover; BOOL isChelsea; } @property(nonatomic,retain)UIPopoverController* popover; @end #import "popController.h" @implementation popController @synthesize popover = _popover; //定义选项显示内容 const char* chelsea[12] = {"博阿斯","切赫","阿什利科尔","特里","路易斯","伊万诺维奇","兰帕德","拉米雷斯","梅来雷斯","阿内尔卡","德罗巴","托雷斯"}; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. isChelsea = NO; //添加完成按钮 UISegmentedControl* doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Done", nil]]; [doneButton setSegmentedControlStyle:UISegmentedControlStyleBar]; [doneButton setFrame:CGRectMake(self.view.bounds.origin.x+self.view.bounds.size.width-100, self.view.bounds.origin.y+5, 75, 50)]; [doneButton addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:doneButton]; [doneButton release]; //添加选择项 UISegmentedControl* clubSeg = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Chelsea",@"AC Milan",@"Livupoor",@"Asenal",nil]]; [clubSeg setSegmentedControlStyle:UISegmentedControlStyleBar]; [clubSeg setFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75,self.view.bounds.size.width,50)]; [clubSeg addTarget:self action:@selector(chooseClub:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:clubSeg]; [clubSeg release]; //添加选择列表 UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+150, self.view.bounds.size.width,self.view.bounds.size.height)]; [picker setBounds:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75, self.view.bounds.size.width,self.view.bounds.size.height)]; picker.delegate = self; picker.dataSource = self; picker.showsSelectionIndicator = YES; [self.view addSubview:picker]; [picker setTag:101]; [picker release]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 1; } -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ return 12; } -(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ if (isChelsea) { return [NSString stringWithCString:chelsea[row] encoding:NSUTF8StringEncoding]; }else{ return [NSString stringWithFormat:@"chelsea_%d",arc4random()%12]; ; } } -(void)segmentAction:(UISegmentedControl*)seg{ [self.view removeFromSuperview]; [self.popover dismissPopoverAnimated:YES]; } -(void)chooseClub:(UISegmentedControl*)seg{ NSInteger index = seg.selectedSegmentIndex; UIPickerView* picker = (UIPickerView*)[self.view viewWithTag:101]; switch (index) { case 0:{ NSLog(@"you choose Chelsea"); isChelsea = YES; [picker reloadAllComponents]; break; } case 1: NSLog(@"you choose AC Milan"); isChelsea = NO; [picker reloadAllComponents]; case 2: NSLog(@"you choose Livopoor"); isChelsea = NO; [picker reloadAllComponents]; case 3: NSLog(@"you choose Asenal"); isChelsea = NO; [picker reloadAllComponents]; default: break; } } @end @property(nonatomic,retain)UIPopoverController* popover; @end
#import <UIKit/UIKit.h> @interface UIActionSheetDemoViewController : UIViewController<UIPopoverControllerDelegate>{ UIPopoverController* _popover; } #import "UIActionSheetDemoViewController.h" #import "popController.h" @implementation UIActionSheetDemoViewController @synthesize popover = _popover; - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; UISegmentedControl* settingView = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"FootballCF",@"BasketballCF",nil]]; [settingView setSegmentedControlStyle:UISegmentedControlStyleBar]; [settingView setFrame:CGRectMake(500, 900, 160, 75)]; [settingView setNeedsLayout]; [settingView addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:settingView]; [settingView release]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; if (self.popover != nil) { [self.popover release]; self.popover = nil; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } -(void)segmentAction:(UISegmentedControl*)seg{ //清除已经显示的弹出窗口 if (self.popover.popoverVisible) { [self.popover dismissPopoverAnimated:YES]; } //初始化待显示控制器 popController* controller = [[popController alloc] init]; //设置待显示控制器的范围 [controller.view setFrame:CGRectMake(550, 490, 350, 450)]; //设置待显示控制器视图的尺寸 controller.contentSizeForViewInPopover = CGSizeMake(350, 450); //初始化弹出窗口 UIPopoverController* pop = [[UIPopoverController alloc] initWithContentViewController:controller]; controller.popover = pop; self.popover = pop; self.popover.delegate = self; //设置弹出窗口尺寸 self.popover.popoverContentSize = CGSizeMake(350, 450); //显示,其中坐标为箭头的坐标以及尺寸 [self.popover presentPopoverFromRect:CGRectMake(550, 890, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO]; [controller release]; [pop release]; //[self.popover dismissPopoverAnimated:YES]; } -(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{ NSLog(@"popover dismiss"); } @end #import <UIKit/UIKit.h> @interface popController : UIViewController<UIPickerViewDelegate,UIPickerViewDataSource>{ UIPopoverController* _popover; BOOL isChelsea; } @property(nonatomic,retain)UIPopoverController* popover; @end #import "popController.h" @implementation popController @synthesize popover = _popover; //定义选项显示内容 const char* chelsea[12] = {"博阿斯","切赫","阿什利科尔","特里","路易斯","伊万诺维奇","兰帕德","拉米雷斯","梅来雷斯","阿内尔卡","德罗巴","托雷斯"}; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. }
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. isChelsea = NO; //添加完成按钮 UISegmentedControl* doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Done", nil]]; [doneButton setSegmentedControlStyle:UISegmentedControlStyleBar]; [doneButton setFrame:CGRectMake(self.view.bounds.origin.x+self.view.bounds.size.width-100, self.view.bounds.origin.y+5, 75, 50)]; [doneButton addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:doneButton]; [doneButton release]; //添加选择项 UISegmentedControl* clubSeg = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Chelsea",@"AC Milan",@"Livupoor",@"Asenal",nil]]; [clubSeg setSegmentedControlStyle:UISegmentedControlStyleBar]; [clubSeg setFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75,self.view.bounds.size.width,50)]; [clubSeg addTarget:self action:@selector(chooseClub:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:clubSeg]; [clubSeg release]; //添加选择列表 UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+150, self.view.bounds.size.width,self.view.bounds.size.height)]; [picker setBounds:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75, self.view.bounds.size.width,self.view.bounds.size.height)]; picker.delegate = self; picker.dataSource = self; picker.showsSelectionIndicator = YES; [self.view addSubview:picker]; [picker setTag:101]; [picker release]; } -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 1; } -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ return 12; } -(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ if (isChelsea) { return [NSString stringWithCString:chelsea[row] encoding:NSUTF8StringEncoding]; }else{ return [NSString stringWithFormat:@"chelsea_%d",arc4random()%12]; ; } } -(void)segmentAction:(UISegmentedControl*)seg{ [self.view removeFromSuperview]; [self.popover dismissPopoverAnimated:YES]; } -(void)chooseClub:(UISegmentedControl*)seg{ NSInteger index = seg.selectedSegmentIndex; UIPickerView* picker = (UIPickerView*)[self.view viewWithTag:101]; switch (index) { case 0:{ NSLog(@"you choose Chelsea"); isChelsea = YES; [picker reloadAllComponents]; break; } case 1: NSLog(@"you choose AC Milan"); isChelsea = NO; [picker reloadAllComponents]; case 2: NSLog(@"you choose Livopoor"); isChelsea = NO; [picker reloadAllComponents]; case 3: NSLog(@"you choose Asenal"); isChelsea = NO; [picker reloadAllComponents]; default: break; } } @end @property(nonatomic,retain)UIPopoverController* popover; @end #import <UIKit/UIKit.h> @interface UIActionSheetDemoViewController : UIViewController<UIPopoverControllerDelegate>{ UIPopoverController* _popover; } #import "UIActionSheetDemoViewController.h" #import "popController.h" @implementation UIActionSheetDemoViewController @synthesize popover = _popover; - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; UISegmentedControl* settingView = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"FootballCF",@"BasketballCF",nil]]; [settingView setSegmentedControlStyle:UISegmentedControlStyleBar]; [settingView setFrame:CGRectMake(500, 900, 160, 75)]; [settingView setNeedsLayout]; [settingView addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:settingView]; [settingView release]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; if (self.popover != nil) { [self.popover release]; self.popover = nil; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } -(void)segmentAction:(UISegmentedControl*)seg{ //清除已经显示的弹出窗口 if (self.popover.popoverVisible) { [self.popover dismissPopoverAnimated:YES]; } //初始化待显示控制器 popController* controller = [[popController alloc] init]; //设置待显示控制器的范围 [controller.view setFrame:CGRectMake(550, 490, 350, 450)]; //设置待显示控制器视图的尺寸 controller.contentSizeForViewInPopover = CGSizeMake(350, 450); //初始化弹出窗口 UIPopoverController* pop = [[UIPopoverController alloc] initWithContentViewController:controller]; controller.popover = pop; self.popover = pop; self.popover.delegate = self; //设置弹出窗口尺寸 self.popover.popoverContentSize = CGSizeMake(350, 450); //显示,其中坐标为箭头的坐标以及尺寸 [self.popover presentPopoverFromRect:CGRectMake(550, 890, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO]; [controller release]; [pop release]; //[self.popover dismissPopoverAnimated:YES]; } -(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{ NSLog(@"popover dismiss"); } @end #import <UIKit/UIKit.h> @interface popController : UIViewController<UIPickerViewDelegate,UIPickerViewDataSource>{ UIPopoverController* _popover; BOOL isChelsea; } @property(nonatomic,retain)UIPopoverController* popover; @end #import "popController.h" @implementation popController @synthesize popover = _popover; //定义选项显示内容 const char* chelsea[12] = {"博阿斯","切赫","阿什利科尔","特里","路易斯","伊万诺维奇","兰帕德","拉米雷斯","梅来雷斯","阿内尔卡","德罗巴","托雷斯"}; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. isChelsea = NO; //添加完成按钮 UISegmentedControl* doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Done", nil]]; [doneButton setSegmentedControlStyle:UISegmentedControlStyleBar]; [doneButton setFrame:CGRectMake(self.view.bounds.origin.x+self.view.bounds.size.width-100, self.view.bounds.origin.y+5, 75, 50)]; [doneButton addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:doneButton]; [doneButton release]; //添加选择项 UISegmentedControl* clubSeg = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Chelsea",@"AC Milan",@"Livupoor",@"Asenal",nil]]; [clubSeg setSegmentedControlStyle:UISegmentedControlStyleBar]; [clubSeg setFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75,self.view.bounds.size.width,50)]; [clubSeg addTarget:self action:@selector(chooseClub:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:clubSeg]; [clubSeg release]; //添加选择列表 UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+150, self.view.bounds.size.width,self.view.bounds.size.height)]; [picker setBounds:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75, self.view.bounds.size.width,self.view.bounds.size.height)]; picker.delegate = self; picker.dataSource = self; picker.showsSelectionIndicator = YES; [self.view addSubview:picker]; [picker setTag:101]; [picker release]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 1; } -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ return 12; } -(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ if (isChelsea) { return [NSString stringWithCString:chelsea[row] encoding:NSUTF8StringEncoding]; }else{ return [NSString stringWithFormat:@"chelsea_%d",arc4random()%12]; ; } } -(void)segmentAction:(UISegmentedControl*)seg{ [self.view removeFromSuperview]; [self.popover dismissPopoverAnimated:YES]; } -(void)chooseClub:(UISegmentedControl*)seg{ NSInteger index = seg.selectedSegmentIndex; UIPickerView* picker = (UIPickerView*)[self.view viewWithTag:101]; switch (index) { case 0:{ NSLog(@"you choose Chelsea"); isChelsea = YES; [picker reloadAllComponents]; break; } case 1: NSLog(@"you choose AC Milan"); isChelsea = NO; [picker reloadAllComponents]; case 2: NSLog(@"you choose Livopoor"); isChelsea = NO; [picker reloadAllComponents]; case 3: NSLog(@"you choose Asenal"); isChelsea = NO; [picker reloadAllComponents]; default: break; } } @end @property(nonatomic,retain)UIPopoverController* popover; @end #import <UIKit/UIKit.h> @interface UIActionSheetDemoViewController : UIViewController<UIPopoverControllerDelegate>{ UIPopoverController* _popover; } #import "UIActionSheetDemoViewController.h" #import "popController.h" @implementation UIActionSheetDemoViewController @synthesize popover = _popover; - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; UISegmentedControl* settingView = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"FootballCF",@"BasketballCF",nil]]; [settingView setSegmentedControlStyle:UISegmentedControlStyleBar]; [settingView setFrame:CGRectMake(500, 900, 160, 75)]; [settingView setNeedsLayout]; [settingView addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:settingView]; [settingView release]; } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; if (self.popover != nil) { [self.popover release]; self.popover = nil; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } -(void)segmentAction:(UISegmentedControl*)seg{ //清除已经显示的弹出窗口 if (self.popover.popoverVisible) { [self.popover dismissPopoverAnimated:YES]; } //初始化待显示控制器 popController* controller = [[popController alloc] init]; //设置待显示控制器的范围 [controller.view setFrame:CGRectMake(550, 490, 350, 450)]; //设置待显示控制器视图的尺寸 controller.contentSizeForViewInPopover = CGSizeMake(350, 450); //初始化弹出窗口 UIPopoverController* pop = [[UIPopoverController alloc] initWithContentViewController:controller]; controller.popover = pop; self.popover = pop; self.popover.delegate = self; //设置弹出窗口尺寸 self.popover.popoverContentSize = CGSizeMake(350, 450); //显示,其中坐标为箭头的坐标以及尺寸 [self.popover presentPopoverFromRect:CGRectMake(550, 890, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO]; [controller release]; [pop release]; //[self.popover dismissPopoverAnimated:YES]; } -(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{ NSLog(@"popover dismiss"); } @end #import <UIKit/UIKit.h> @interface popController : UIViewController<UIPickerViewDelegate,UIPickerViewDataSource>{ UIPopoverController* _popover; BOOL isChelsea; } @property(nonatomic,retain)UIPopoverController* popover; @end #import "popController.h" @implementation popController @synthesize popover = _popover; //定义选项显示内容 const char* chelsea[12] = {"博阿斯","切赫","阿什利科尔","特里","路易斯","伊万诺维奇","兰帕德","拉米雷斯","梅来雷斯","阿内尔卡","德罗巴","托雷斯"}; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. isChelsea = NO; //添加完成按钮 UISegmentedControl* doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Done", nil]]; [doneButton setSegmentedControlStyle:UISegmentedControlStyleBar]; [doneButton setFrame:CGRectMake(self.view.bounds.origin.x+self.view.bounds.size.width-100, self.view.bounds.origin.y+5, 75, 50)]; [doneButton addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:doneButton]; [doneButton release]; //添加选择项 UISegmentedControl* clubSeg = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Chelsea",@"AC Milan",@"Livupoor",@"Asenal",nil]]; [clubSeg setSegmentedControlStyle:UISegmentedControlStyleBar]; [clubSeg setFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75,self.view.bounds.size.width,50)]; [clubSeg addTarget:self action:@selector(chooseClub:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:clubSeg]; [clubSeg release]; //添加选择列表 UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+150, self.view.bounds.size.width,self.view.bounds.size.height)]; [picker setBounds:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y+75, self.view.bounds.size.width,self.view.bounds.size.height)]; picker.delegate = self; picker.dataSource = self; picker.showsSelectionIndicator = YES; [self.view addSubview:picker]; [picker setTag:101]; [picker release]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 1; } -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ return 12; } -(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ if (isChelsea) { return [NSString stringWithCString:chelsea[row] encoding:NSUTF8StringEncoding]; }else{ return [NSString stringWithFormat:@"chelsea_%d",arc4random()%12]; ; } } -(void)segmentAction:(UISegmentedControl*)seg{ [self.view removeFromSuperview]; [self.popover dismissPopoverAnimated:YES]; } -(void)chooseClub:(UISegmentedControl*)seg{ NSInteger index = seg.selectedSegmentIndex; UIPickerView* picker = (UIPickerView*)[self.view viewWithTag:101]; switch (index) { case 0:{ NSLog(@"you choose Chelsea"); isChelsea = YES; [picker reloadAllComponents]; break; } case 1: NSLog(@"you choose AC Milan"); isChelsea = NO; [picker reloadAllComponents]; case 2: NSLog(@"you choose Livopoor"); isChelsea = NO; [picker reloadAllComponents]; case 3: NSLog(@"you choose Asenal"); isChelsea = NO; [picker reloadAllComponents]; default: break; } } @end