在ToolBar上添加SegmentedControl
来源:互联网 发布:福建省文化厅网络审批 编辑:程序博客网 时间:2024/06/11 01:37
在ToolBar上添加SegmentedControl
学习iphone这么长时间,还没怎么用过ToolBar,今天项目需求,要用到它。本以为很容易用,结果发现想在ToolBar上添加一个segmentedControl就把我难住了一下下。
ToolBar上所有的Items都必须是UIBarButtonItem类型的,因此需要先把SegmentedControl转变成UIBarButtonItem才能加上去。
toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 372, 320, 44)];
UIBarButtonItem *todayItem = [[UIBarButtonItem alloc] initWithTitle:@"今日"
style:UIBarButtonItemStyleBordered
target:self action:@selector(backToToday)];
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil action:nil];
segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:@"日",@"周",@"月",nil]];
[segmentedControl setFrame:CGRectMake(0, 0, 150, 30)];
[segmentedControl setSegmentedControlStyle:UISegmentedControlStyleBar];
segmentedControl.selectedSegmentIndex = 0;
[segmentedControl addTarget:self action:@selector(segmentChanged:)
forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *segmentItem = [[UIBarButtonItem alloc]
initWithCustomView:segmentedControl];
[segmentedControl release];
NSArray *array = [[NSArray alloc] initWithObjects:todayItem,spaceItem,
segmentItem,spaceItem,nil];
[todayItem release];
[spaceItem release];
[segmentItem release];
[toolBar setItems:array];
[array release];
[self.view addSubview:toolBar];
- 在ToolBar上添加SegmentedControl
- 在Toolbar上添加Edit控件
- tinymce 应用:在ToolBar上添加一个listbox
- ios7上SegmentedControl 图片使用
- SegmentedControl
- 键盘上添加toolbar 添加Button
- 在对话框中添加TOOLBAR
- 在ArcGisEngine 开发中如何在Toolbar控件上添加Combobox等其他控件
- 在工具栏Toolbar上添加常用控件的编程思路和示例
- 修改ALV 工具条,在ALV toolbar上添加、移除按钮
- 在VS2008中添加toolbar按钮功能
- 在datagrid中的toolbar添加输入框
- uitextfield键盘上添加Toolbar 再添加Done按钮
- 在ToolBar上使用半透明图像
- 添加toolbar
- android5.0之往toolbar上添加按钮
- 在工具栏(ToolBar)上添加ComboBox控件,为何每次在下拉列表中选择时,都会自动的选中工具栏上的一个按钮?
- 如何在toolbar中添加新的工具条
- 范式Huffman编码的设计与实现
- 强连通分量tarjan
- socket select()用法
- 验证数字的正则表达式集
- poj2492A Bug's Life(并查集详解)
- 在ToolBar上添加SegmentedControl
- eclipse下安装gwt
- SQL触发器
- 使用 shell 脚本对 Linux 系统和进程资源进行监控
- Android使用CountDownTimer实现倒计时功能
- PreferenceActivity 参数设置UI的使用
- storm作者个人博客网址
- C# BackgroundWorker组件学习
- MyBatis学习 之 一、MyBatis简介与配置MyBatis+Spring+MySql