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(5)-os模块
os.getcwd() 获取当前工作目录 os.chdir('dirname') 改变当前脚本的工作目录 os.curdir 返回当前目录名,即"." os.pardir 返回当前 ...
- oracle锁
1.概念 数据库中有两种基本的锁类型:排它锁(Exclusive Locks,即X锁)和共享锁(Share Locks,即S锁). 当数据对象被加上排它锁时,其他的事务不能对它读取和修改:加了共享锁的 ...
- sequence 作为序列插入值不是第一个
CREATE SEQUENCE seq_test INCREMENT BY 1 START WITH 1 ; 创建表时 或执行 ALTER SYSTEM SET deferred_segment_c ...
- ORACLE之PACKAGE-游标变量
刚学pl/sql编程,写了两个package.pkg_temp_fn31和pkg_temp_fn32.内容涉及pl/sql基本语法,游标变量,存储过程(in,out). pkg_temp_fn31调用 ...
- stop()方法的精准应用
stop()方法在动画中扮演了很精彩的角色,他能够阻止连续动画或连续事件出现累积的状况,令动画有条不紊的进行. 1语法结构 stop([clearQueue],[gotoEnd]); 这两个参数都是可 ...
- MyBatis(3.2.3) - Integration with Spring
MyBatis-Spring is a submodule of the MyBatis framework, which provides seamless integration with the ...
- HTTP - 摘要认证
基本认证便捷灵活,但极不安全.用户名和密码都是以明文形式传送的,也没有采取任何措施防止对报文的篡改.安全使用基本认证的唯一方式就是将其与 SSL 配合使用. 摘要认证是另一种 HTTP 认证协议,它与 ...
- Git CMD - branch: List, create, or delete branches
命令格式 git branch [--color[=<when>] | --no-color] [-r | -a] [--list] [-v [--abbrev=<length> ...
- sqlserver根据id集合,批量插入。(巧用sqlserver内置函数)
场景如下,传入的id,如1,3,4,88.可以在.net后台处理,但是我更习惯在数据库中操作. 插入数据时可以这样处理,直接贴代码. CREATE PROCEDURE pro_CategorySave ...
- Oracle表空间操作
-- 查看表空间 SELECT tablespace_name, file_id, file_name, ), )||'M' total_space FROM dba_data_files ORDER ...