ios NavBar+TarBar技巧
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技巧的更多相关文章
- iOS:小技巧(不断更新)
记录下一些不常用技巧,以防忘记,复制用. 1.获取当前的View在Window的frame: UIWindow * window=[[[UIApplication sharedApplication] ...
- iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式
iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式 说明: 1)该文简短介绍在iOS开发中遍历字典.数组和集合的几种常见方式. 2)该文对应的代码可以在下面的地址获得:https:// ...
- iOS开发实用技巧—在手机浏览器头部弹出app应用下载提示
iOS开发实用技巧—在手机浏览器头部弹出app应用下载提示 本文介绍其简单使用: 第一步:在本地建立一个访问的服务端. 打开本地终端,在本地新建一个文件夹,在该文件夹中存放测试的html页面. ...
- iOS开发实用技巧—项目新特性页面的处理
iOS开发实用技巧篇—项目新特性页面的处理 说明:本文主要说明在项目开发中会涉及到的最最简单的新特性界面(实用UIScrollView展示多张图片的轮播)的处理. 代码示例: 新建一个专门的处理新特性 ...
- iOS开发小技巧 - UILabel添加中划线
iOS开发小技巧 遇到的问题: 给Label添加中划线,然后并没有效果 NSString *str = [NSString stringWithFormat:@"合计金额 ¥%.2f&quo ...
- iOS开发小技巧 - runtime适配字体
iOS开发小技巧 - runtime适配字体 版权声明:本文为博主原创文章,未经博主允许不得转载,有问题可联系博主Email: liuyongjiesail@icloud.com 一个iOS开发项目无 ...
- iOS:小技巧(19-02-12更)
记录下一些不常用技巧,以防忘记,复制用. 1.UIImageView 和UILabel 等一些控件,需要加这句才能成功setCorn _myLabel.layer.masksToBounds = YE ...
- iOS开发--常用技巧 (MJRefresh详解)
iOS开发--常用技巧 (MJRefresh详解) https://github.com/CoderMJLee/MJRefresh 下拉刷新01-默认 self.tableView.head ...
- iOS 页面流畅技巧(1)
一.屏幕显示图像原理 首先明确两个概念:水平同步信号.垂直同步信号. CRT 的电子枪按照上图中的方式,从上到下一行一行的扫描,扫描完成后显示器就呈现一帧画面,随后电子枪回到初始位置继续下一次的扫描. ...
随机推荐
- python(4)-迭代器 和 生成器
迭代器是访问集合元素的一种方式.迭代器适合遍历一些巨大或无限的集合,比如几个G的文件.迭代器具有以下特点: 1. 访问者不需要关心迭代器内部的结构,只需通过__next__()方法不断取下一个内容 2 ...
- c# 友元程序集
在团队开发中,如果一个程序集中要调用另外一个程序集,但是要被调用的那个程序集又不想用public来公开自己的类, 那么怎么办,就是用最后一种internal来用来做类的可见性了. 下面来看一个简单例子 ...
- 关于eclipse中删除多余的工作空间记录
这个Eclipse是拷贝的别人的,前三个是别人在使用这个Eclipse的时候定义的路径,到我本地机器是多余的.如何删除这三个默认的工作空间路径. 这个路径的list是读取的Eclipse中的一个文件, ...
- 关于hadoop2.4.1伪分布式系统的搭建
1.准备Linux环境 1.0点击VMware快捷方式,右键打开文件所在位置 -> 双击vmnetcfg.exe -> VMnet1 host-only ->修改subnet ip ...
- hdu 2196 树形dp
思路:先求以1为根时,每个节点到子节点的最大长度.然后再次从1进入进行更新. #include<iostream> #include<cstring> #include< ...
- BZOJ 2962
2962: 序列操作 Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 618 Solved: 225[Submit][Status][Discuss] ...
- poj1472[模拟题]
Instant Complexity Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2017 Accepted: 698 ...
- 在 Tomcat 中设置 JDBCRealm
除了默认配置的 DataSourceRealm,Tomcat 还支持 JDBCRealm,它通过 JDBC 来访问记录在关系数据库里的认证信息. JDBCRealm 的配置步骤如下: 在 $TOMCA ...
- Git CMD - tag: Create, list, delete or verify a tag object signed with GPG
命令格式 git tag [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>] <tagname> [& ...
- Global.asax中的操作数据库代码无法执行
本人最近在做一个基于Access数据库的Web应用程序,为了实现一个定时更新数据库的需求,我在Global.asax中的Application_Start函数里写了个计时器, void Applica ...