IOS开发基础知识--碎片2
六:获得另一个控件器,并实现跳转
UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *registerViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"registerViewController"];
registerViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:registerViewController animated:YES completion:^{
NSLog(@"Present Modal View");
}];
另一种用segue连接:
如果在storyboard中当前的ViewController和要跳转的ViewController之间的segue之间存在,则可以执行performSegueWithIdentifier:sender:这个方法实现跳转。
比如:[self performSegueWithIdentifier:@"go" sender:self];
其中,go为自己定义的segue标识符。
其中registerViewController是第二个视图中标识检查器Storyboard ID的值
七:判断IOS版本
判断IOS是不是7.0以后的
if([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0) {
}
八:Button不同状态下背景图片
[_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-n.png"] forState:UIControlStateNormal];
[_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-s.png"] forState:UIControlStateHighlighted];
九:判断设备是3.5寸还是4寸
if ([[UIScreen mainScreen] currentMode].size.height == 480||[[UIScreenmainScreen] currentMode].size.height == 960)
{
//这是3.5寸的iPhone设备
}
else
{ //这是4寸的iPhone设备 }
十:viewDidLoad中调用
无论你是通过xib文件还是重写loadView方法创建UIViewController的view,在view创建完毕后,最终都会调用viewDidLoad方法,一般我们会在这里做界面上的初始化操作,比如往view中添加一些子视图、从数据库或者网络加载模型数据装配到子视图中
- (void)viewDidLoad
{
[super viewDidLoad]; // 添加一个按钮
UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
[button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
十一:树形结构导航问题(UINavigationController)
1:如何修改第二页的返回back文字
应该在第一页的viewDidLoad里面进行修改(假设从A界面push到B界面,希望改变B界面的返回按钮标题,则在A界面中加入代码),代码如下:
-(void)viewDidLoad
{
UIBarButtonItem *backItem = [[[UIBarButtonItem alloc] init] autorelease]; backItem.title = @"返回"; self.navigationItem.backBarButtonItem = backItem;
}
2:如何增加一个控件在标头
在本页的viewDidLoad里面进行增加;代码如下:
-(void)viewDidLoad
{
UIBarButtonItem* Done=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(DownShow)];
self.navigationItem.rightBarButtonItem=Done;
} -(void)DownShow
{ }
其中按键类型如下(带有不同的图标):
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo,
UIBarButtonSystemItemRedo,
UIBarButtonSystemItemPageCurl//只能在ToolBar上显示
3:如何修改标头的色彩
self.navigationController.navigationBar.tintColor=[UIColor redColor];
4:增加其它UISegment,UISwith控件
在本页viewDidLoad中增加如下代码,
UISegmentedControl *mySegment;
mySegment = [[UISegmentedControl alloc] initWithFrame:CGRectMake(218.0f, 8.0, 100.0f, 30.0f)];
[mySegment insertSegmentWithTitle:@"分配" atIndex: animated:YES];
[mySegment insertSegmentWithTitle:@"处理" atIndex: animated:YES];
mySegment.segmentedControlStyle = UISegmentedControlStyleBar;
mySegment.selectedSegmentIndex = ;
[self.navigationController.navigationBar addSubview:mySegment];
IOS开发基础知识--碎片2的更多相关文章
- IOS开发基础知识碎片-导航
1:IOS开发基础知识--碎片1 a:NSString与NSInteger的互换 b:Objective-c中集合里面不能存放基础类型,比如int string float等,只能把它们转化成对象才可 ...
- IOS开发基础知识--碎片33
1:AFNetworking状态栏网络请求效果 直接在AppDelegate里面didFinishLaunchingWithOptions进行设置 [[AFNetworkActivityIndicat ...
- IOS开发基础知识--碎片42
1:报thread 1:exc_bad_access(code=1,address=0x70********) 闪退 这种错误通常是内存管理的问题,一般是访问了已经释放的对象导致的,可以开启僵尸对象( ...
- IOS开发基础知识--碎片50
1:Masonry 2个或2个以上的控件等间隔排序 /** * 多个控件固定间隔的等间隔排列,变化的是控件的长度或者宽度值 * * @param axisType 轴线方向 * @param fi ...
- IOS开发基础知识--碎片3
十二:判断设备 //设备名称 return [UIDevice currentDevice].name; //设备型号,只可得到是何设备,无法得到是第几代设备 return [UIDevice cur ...
- IOS开发基础知识--碎片11
1:AFNetwork判断网络状态 #import “AFNetworkActivityIndicatorManager.h" - (BOOL)application:(UIApplicat ...
- IOS开发基础知识--碎片14
1:ZIP文件压缩跟解压,使用ZipArchive 创建/添加一个zip包 ZipArchive* zipFile = [[ZipArchive alloc] init]; //次数得zipfilen ...
- IOS开发基础知识--碎片16
1:Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id) 对象在运行时获取其类型的能力称为内省.内省可以有多种方法实现. 判断对象类型 -(BOO ...
- IOS开发基础知识--碎片19
1:键盘事件顺序 UIKeyboardWillShowNotification // 键盘显示之前 UIKeyboardDidShowNotification // 键盘显示完成后 UIKeyboar ...
- IOS开发基础知识--碎片40
1:Masonry快速查看报错小技巧 self.statusLabel = [UILabel new]; [self.contentView addSubview:self.statusLabel]; ...
随机推荐
- BAT及各大互联网公司2014前端笔试面试题--Html,Css篇
很多面试题是我自己面试BAT亲身经历碰到的.整理分享出来希望更多的前端er共同进步吧,不仅适用于求职者,对于巩固复习前端基础更是大有裨益. 而更多的题目是我一路以来收集的,也有往年的,答案不确保一定正 ...
- EasyUI DataGrid formatter 格式化增加链接
function fLoadTable() { $('#tt').datagrid({ title: '', ...
- 出操队形(LIS)
题目来源:微策略2013年校园招聘面试一面试题 题目描述: 在读高中的时候,每天早上学校都要组织全校的师生进行跑步来锻炼身体,每当出操令吹响时,大家就开始往楼下跑了,然后身高矮的排在队伍的前面,身高较 ...
- 使用Jquery的Ajax实现无刷新更新,修改,删除页面
本文将向大家讲述一下最近工作的一些总结,主要包括了以下内容,注册界面以及详细信息界面的编辑.主要是介绍了AJAX技术,因为我觉得其他方面没什么好介绍的.首先是跟大家说一下Ajax的优点,假如你删除了一 ...
- 转:C语言中的头文件可以自己写吗?
转自:http://www.eefocus.com/computer00/blog/08-09/155791_9ebdc.html 一些初学C语言的人,不知道头文件(*.h文件)原来还可以自己写的. ...
- PHP连接SQL Server相关配置及说明
关于php怎么连接数据库,大家肯定有不同的看法,有的用wamp,有的用xamp,他们都是集成环境,方便操作.但有时,数据库的类型不同,要连接不同的数据库.今天和大家分享一下如何连接sql2000,服 ...
- 分享我基于NPOI+ExcelReport实现的导入与导出EXCEL类库:ExcelUtility (续3篇-导出时动态生成多Sheet EXCEL)
ExcelUtility 类库经过我(梦在旅途)近期不断的优化与新增功能,现已基本趋向稳定,功能上也基本可以满足绝大部份的EXCEL导出需求,该类库已在我们公司大型ERP系统全面使用,效果不错,今天应 ...
- JS魔法堂:定义页面的Dispose方法——[before]unload事件启示录
前言 最近实施的同事报障,说用户审批流程后直接关闭浏览器,操作十余次后系统就报用户会话数超过上限,咨询4A同事后得知登陆后需要显式调用登出API才能清理4A端,否则必然会超出会话上限. 即使在页面 ...
- 用Vagrant和Ansible搭建持续交付平台
这是一个关于Vagrant的学习系列,包含如下文章: Vagrant入门 创建自己的Vagrant box 用Vagrant搭建Jenkins构建环境 用Vagrant和Ansible搭建持续交付平台 ...
- Effective java笔记(四),泛型
泛型为集合提供了编译时类型检查. 23.不要在代码中使用原生态类型 声明中具有一个或多个类型参数的类或接口统称为泛型.List<E>是一个参数化类,表示元素类型为E的列表.为了提供兼容性, ...