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];
- 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"]];
- 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"]];
- // [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"];
- 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]
本文链接:http://www.cnblogs.com/lovewx/archive/2014/08/04/3890664.html