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. jboss加密敏感信息

    默认情况下,我们配置在domain.xml或host.xml文件中的信息都是明文,对一些敏感信息就显得安全性不够,可以使用jboss提供的vault机制来进行加密 下面的内容来自 http://www ...

  2. ZOJ 3209 Treasure Map (Dancing Links)

    Treasure Map Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit S ...

  3. LeetCode 11

    Container With Most Water Given n non-negative integers a1, a2, ..., an, where each represents a poi ...

  4. [改善Java代码]不要让四舍五入亏了一方

    建议25: 不要让四舍五入亏了一方 本建议还是来重温一个小学数学问题:四舍五入.四舍五入是一种近似精确的计算方法,在Java 5之前,我们一般是通过使用Math.round来获得指定精度的整数或小数的 ...

  5. nmap命令-----基础用法

    系统漏洞扫描之王-nmap   NMap,也就是Network Mapper,是Linux下的网络扫描和嗅探工具包.   其基本功能有三个: (1)是扫描主机端口,嗅探所提供的网络服务 (2)是探测一 ...

  6. Linux 命令 - passwd: 更改用户密码

    命令格式 passwd  [-k]  [-l]  [-u  [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w warndays] [-i inactiveda ...

  7. Unity3d导入工程出现错误“Creating unique file”的解决方法

    Unity3d导入工程出现错误“Creating unique file:creating file Temp/tempFile failed.Please ensure there is enoug ...

  8. HDOJ2001计算两点间的距离

    计算两点间的距离 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  9. javaweb 乱码总结

    可能的错误地方: 1.jsp页面编码 2.表单编码 3.servlet可接受编码 4.tomcat中server.xml文件中的指定编码 所有的编码要统一,一般使用“UTF-8”比较好 我最近一次出错 ...

  10. kettle 表输入+流查询 与 数据库查询

    他们的主要区别: •流查询步骤只能进行等值查询,数据库查询步骤可以进行非等值查询 •流查询在查询之前把数据都加载到内存里,数据库查询可以选择是否把数据加载到内存. •进行等值查询时,数据库查询步骤如果 ...