NavBar+TarBar

iphone开发 NavBar+TarBar

1  改变NavBar颜色:选中Navigation Bar 的Tint属性。选中颜色。

2  隐藏“back”按钮: self.navigationItem.hidesBackButton = YES;

3 隐藏"NavBar" : self.navigationController.navigationBarHidden = YES;

4 可以不用MainWindow.xib创建的Navigation。在每个view上自定义。

需要把每个控制页都加上以下代码来隐藏nav:

-(void)viewWillAppear:(BOOL)animated

{

self.navigationController.navigationBarHidden = YES;//显示"NavBar"

}

然后在每个控制页xib自己添加Navigation Bar。添加所需BarButtonItem按钮。

5 页面跳转隐藏tarbar :

HomeDetailViewController *detailview = [[HomeDetailViewController alloc] initWithNibName:@"HomeDetailView" bundle:nil];

detailview.hidesBottomBarWhenPushed = YES;//隐藏tarbar

[self.navigationController pushViewController:detailview animated:YES];

[detailview     release];

6 页面返回:

[self.navigationController popViewControllerAnimated:YES];

7 默认选中tabbar为第一个view:

TabBarController.selectedIndex= 0;

其他:

8 已知两地经纬度 计算两地之间的距离:

//    地图显示当前位置:

mapView.showsUserLocation=YES;

CLLocationManager *locationManager = [[CLLocationManager alloc] init];//创建位置管理器

locationManager.delegate=self;//设置代理

locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度级别为最佳精度

locationManager.distanceFilter=1000.0f;//设置距离筛选器为任何移动都要发送更新

[locationManager startUpdatingLocation];//启动位置管理器

MKCoordinateSpan theSpan;

//地图的范围 越小越精确

theSpan.latitudeDelta=0.05;

theSpan.longitudeDelta=0.05;

MKCoordinateRegion theRegion;

theRegion.center=[[locationManager location] coordinate];

theRegion.span=theSpan;

[mapView setRegion:theRegion];

[locationManager release];

MKUserLocation *usrLoc=mapView.userLocation;

CLLocationCoordinate2D usrCoordinate=usrLoc.location.coordinate;

NSLog(@"la==%f lo==%f",usrCoordinate.latitude,usrCoordinate.longitude);

//   已知两点的经纬度,计算出两地距离:

CLLocation *location1 = [[[CLLocation alloc] initWithLatitude:usrCoordinate.latitude longitude:usrCoordinate.longitude] autorelease];

CLLocation *location2 = [[[CLLocation alloc] initWithLatitude:36.676445 longitude:117.106793] autorelease];

NSLog(@"JULI====%.0f km", [location1 distanceFromLocation:location2]);//4502

9 取小数点后两位(四舍五入),输出:

NSLog(@"%.02f km",4478.442312);

10 调用打电话API :

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10010"]];

使用这种方式拨打电话时,当用户结束通话后,iphone界面会停留在电话界面。

用如下方式,可以使得用户结束通话后自动返回到应用:

UIWebView*callWebview =[[UIWebView alloc] init];

NSURL *telURL =[NSURL URLWithString:@"tel:10086"];// 貌似tel:// 或者 tel: 都行

[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];

//记得添加到view上

[self.view addSubview:callWebview];

11 调用 SMS发短信:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://15315310992"]];

12 调用自带 浏览器 safari

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@http://www.baidu.com]];

13 在一个程序里打开另一个程序:

首先:plist里添加URL types   点开里边的Item0  添加URLSchemes  打开Item0 输入sinaWeibo

然后在需要调用的地方:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sinaWeibo://*"]];

https://itunes.apple.com/cn/app/qq-2012/id444934666?mt=8

14 双引号转义:

用 \" 表示 双引号

15 设置按钮按下换图片 松开还是原图

//                [danxuan setImage:[UIImage imageNamed:@"exercise_option_n.png"] forState:UIControlStateNormal];

//这个是设置按下的图片,松开就是上面的图片

//               [danxuan setImage:[UIImage imageNamed:@"exercise_option_s.png"] forState:UIControlEventTouchDragOutside];

16  判断数组中是否存在某元素:

BOOL isValue=[keyArray containsObject:@"aaa"];

17 Nav添加button

UIButton *btnBack = [ABUtil createNavigationCtrollerRoundedRectBtn:Localized(@"取消")];

[btnBack addTarget:self

action:@selector(tapLeftBarButton)

forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnBack];

self.navigationItem.leftBarButtonItem = leftBarButtonItem;

[btnBack release];

[leftBarButtonItem release]

ios NavBar+TarBar技巧的更多相关文章

  1. iOS:小技巧(不断更新)

    记录下一些不常用技巧,以防忘记,复制用. 1.获取当前的View在Window的frame: UIWindow * window=[[[UIApplication sharedApplication] ...

  2. iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式

    iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式 说明: 1)该文简短介绍在iOS开发中遍历字典.数组和集合的几种常见方式. 2)该文对应的代码可以在下面的地址获得:https:// ...

  3. iOS开发实用技巧—在手机浏览器头部弹出app应用下载提示

    iOS开发实用技巧—在手机浏览器头部弹出app应用下载提示 本文介绍其简单使用: 第一步:在本地建立一个访问的服务端.  打开本地终端,在本地新建一个文件夹,在该文件夹中存放测试的html页面.   ...

  4. iOS开发实用技巧—项目新特性页面的处理

    iOS开发实用技巧篇—项目新特性页面的处理 说明:本文主要说明在项目开发中会涉及到的最最简单的新特性界面(实用UIScrollView展示多张图片的轮播)的处理. 代码示例: 新建一个专门的处理新特性 ...

  5. iOS开发小技巧 - UILabel添加中划线

    iOS开发小技巧 遇到的问题: 给Label添加中划线,然后并没有效果 NSString *str = [NSString stringWithFormat:@"合计金额 ¥%.2f&quo ...

  6. iOS开发小技巧 - runtime适配字体

    iOS开发小技巧 - runtime适配字体 版权声明:本文为博主原创文章,未经博主允许不得转载,有问题可联系博主Email: liuyongjiesail@icloud.com 一个iOS开发项目无 ...

  7. iOS:小技巧(19-02-12更)

    记录下一些不常用技巧,以防忘记,复制用. 1.UIImageView 和UILabel 等一些控件,需要加这句才能成功setCorn _myLabel.layer.masksToBounds = YE ...

  8. iOS开发--常用技巧 (MJRefresh详解)

         iOS开发--常用技巧 (MJRefresh详解) https://github.com/CoderMJLee/MJRefresh 下拉刷新01-默认 self.tableView.head ...

  9. iOS 页面流畅技巧(1)

    一.屏幕显示图像原理 首先明确两个概念:水平同步信号.垂直同步信号. CRT 的电子枪按照上图中的方式,从上到下一行一行的扫描,扫描完成后显示器就呈现一帧画面,随后电子枪回到初始位置继续下一次的扫描. ...

随机推荐

  1. Kali+Win7双系统

    ----------------------------------------------------------前言---------------------------------------- ...

  2. TCP/IP与UDP区别

    最近面试,问到这方面的问题,这里总结一下: TCP (Transmission  Control  Protocol   传输控制协议):面向连接的,不可靠的,数据流服务.UDP (User  Dat ...

  3. [转]Maintain File Upload Control on Postbacks

    本文转自:http://www.ironspeed.com/articles/Maintain%20File%20Upload%20Control/Article.aspx Introduction ...

  4. CF 13E. Holes 分块数组

    题目:点这 跟这题BZOJ 2002: [Hnoi2010]Bounce 弹飞绵羊  一模一样 分析: 分块数组入门题. 具体的可以学习这篇博文以及做国家集训队2008 - 苏煜<对块状链表的一 ...

  5. ORACLE字符串分组聚合函数(字符串连接聚合函数)

    ORACLE字符串连接分组串聚函数 wmsys.wm_concat SQL代码: select grp, wmsys.wm_concat(str) grp, 'a1' str from dual un ...

  6. sqlserver之二进制和字符串sql语句

    正常情况下我们对数据库的操作就是如下的写法来操作数据库 ID AS 编号,BookName AS 书名 FROM dbo.books ORDER BY ID; ; 但是在客户正在使用的数据库里,我们开 ...

  7. SQL Server的三种物理连接之Loop Join(一)

    Sql Server有三种物理连接Loop Join,Merge Join,Hash Join, 当表之间连接的时候会选择其中之一,不同的连接产生的性能不同,理解这三种物理连接对性能调优有很大帮助. ...

  8. CSS 文字溢出时的自动隐藏

    http://www.111cn.net/cssdiv/css/34050.htm 语法:overflow : visible | auto | hidden | scroll visible::不剪 ...

  9. String str 与 String str=new String("") 区别

    1.当使用String str="abc",这种方式时,先去内存的Heap中找是否存在"abc"这个字符串,若存在,则将地址引用.若不存在则创建. 2.当使用S ...

  10. OpenGL9-(FreeImage)加载图片-作为纹理

    /*** 这个例子展示如何使用FreeImage加载图片作为纹理* 初学者,在学习OpenGL的时候,往往因为OpenGL读图片没有那么方便* 而浪费了大量的时间在研究图片格式上,其实大可不必. 1. ...