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. python(2)-字符串(2)

    字符串格式化: 前面说过一种字符串格式化方法,来复习一下: >>> print('His name is %s', 'jeff') His name is %s jeff 其实格式化 ...

  2. python 元类——metaclass

    from stack overflow:http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python Classes ...

  3. Visual Studio Team Foundation Server 2015(TFS 秘钥、序列号)

    Visual Studio Team Foundation Server 2015 序列号:PTBNK-HVGCM-HB2GW-MXWMH-T3BJQ

  4. .NET学习笔记(1)— C#学习路线图

    目录 一:引言 二:.NET技术体系 三:常用工具汇总 四:学习资源汇总 五:书籍推荐 六:关于阅读技术书籍的经验 七:总结   一:引言 因为工作调整,从PHP开发零基础转型到.NET开发,前期没有 ...

  5. ss 如何解决margin-top使父元素margin失效

    给子元素设置margin-top的时候父元素的也会受影响.会产生子元素和父元素margin合并的问题. 解决办法: 给父元素设置padding.或者border把父子的margin之间隔开. 一般来说 ...

  6. sublime text使用技巧

    常用快捷键 Ctrl + L  选择整行(按住-继续选择下行) Ctrl + KK  从光标处删除至行尾 Ctrl + Shift+K  删除整行 Ctrl + Shift+D  复制光标所在整行,插 ...

  7. 每天一道LeetCode--141.Linked List Cycle(链表环问题)

    Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using ext ...

  8. CSS之Win8界面摸拟

    开门见山,先把测试Result放上: <head> <meta charset="UTF-8"> <meta http-equiv="X-U ...

  9. oracle开启audit(审计)

    1.查看审计功能是否开启(本机已经开启,如果audit_sys_operations值为FALSE就是没开审计) [sql] view plaincopyprint? SQL> CONN /AS ...

  10. 第五篇、Uber用视频播放做启动动画

    import UIKit import AVFoundation class GuidePage: FxBasePage { @IBOutlet var backImageView:UIImageVi ...