自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ios開發(fā)之NavBar和TarBar使用技巧

移動(dòng)開發(fā) iOS
NavBar和TarBar在IOS開發(fā)中經(jīng)常被應(yīng)用,本篇文章將從以下幾個(gè)方面講解ios開發(fā)中NavBar和TarBar的使用技巧。

1 改變NavBar顏色:選中Navigation Bar 的Tint屬性。選中顏色。

2 隱藏“back”按鈕: self.navigationItem.hidesBackButton = YES;

3 隱藏"NavBar" : self.navigationController.navigationBarHidden = YES;

4 可以不用MainWindow.xib創(chuàng)建的Navigation。在每個(gè)view上自定義。

需要把每個(gè)控制頁都加上以下代碼來隱藏nav:

 

-(void)viewWillAppear:(BOOL)animated

 

{

 

self.navigationController.navigationBarHidden = YES;//顯示"NavBar"

 

}

 

然后在每個(gè)控制頁xib自己添加Navigation Bar。添加所需BarButtonItem按鈕。

 

 

 

5 頁面跳轉(zhuǎn)隱藏tarbar :

 

  1. HomeDetailViewController *detailview = [[HomeDetailViewController alloc] initWithNibName:@"HomeDetailView" bundle:nil];  
  2. detailview.hidesBottomBarWhenPushed = YES;//隱藏tarbar  
  3. [self.navigationController pushViewController:detailview animated:YES];  
  4. [detailview     release];  

6 頁面返回:

 

[self.navigationController popViewControllerAnimated:YES]; 

 

 

7 默認(rèn)選中tabbar為***個(gè)view: 

 

TabBarController.selectedIndex= 0;

 

其他:

 

  1. 8 已知兩地經(jīng)緯度 計(jì)算兩地之間的距離:  
  2. //    地圖顯示當(dāng)前位置:  
  3.     mapView.showsUserLocation=YES;  
  4.     CLLocationManager *locationManager = [[CLLocationManager alloc] init];//創(chuàng)建位置管理器  
  5.     locationManager.delegate=self;//設(shè)置代理  
  6.     locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度級(jí)別為***精度  
  7.     locationManager.distanceFilter=1000.0f;//設(shè)置距離篩選器為任何移動(dòng)都要發(fā)送更新  
  8.     [locationManager startUpdatingLocation];//啟動(dòng)位置管理器  
  9.     MKCoordinateSpan theSpan;  
  10.     //地圖的范圍 越小越精確  
  11.     theSpan.latitudeDelta=0.05;  
  12.     theSpan.longitudeDelta=0.05;  
  13.     MKCoordinateRegion theRegion;  
  14.     theRegion.center=[[locationManager location] coordinate];  
  15.     theRegion.span=theSpan;  
  16.     [mapView setRegion:theRegion];  
  17.     [locationManager release];  
  18.      
  19.     MKUserLocation *usrLoc=mapView.userLocation;  
  20.     CLLocationCoordinate2D usrCoordinate=usrLoc.location.coordinate;  
  21.     NSLog(@"la==%f lo==%f",usrCoordinate.latitude,usrCoordinate.longitude);  
  22.      
  23. //   已知兩點(diǎn)的經(jīng)緯度,計(jì)算出兩地距離:  
  24.     CLLocation *location1 = [[[CLLocation alloc] initWithLatitude:usrCoordinate.latitude longitude:usrCoordinate.longitude] autorelease];  
  25.     CLLocation *location2 = [[[CLLocation alloc] initWithLatitude:36.676445 longitude:117.106793] autorelease]; 
  26.     NSLog(@"JULI====%.0f km", [location1 distanceFromLocation:location2]);//4502  

9 取小數(shù)點(diǎn)后兩位(四舍五入),輸出: 

 

NSLog(@"%.02f km",4478.442312);

 

 

10 調(diào)用打電話API : 

 

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10010"]]; 

 

使用這種方式撥打電話時(shí),當(dāng)用戶結(jié)束通話后,iphone界面會(huì)停留在電話界面。 

 

用如下方式,可以使得用戶結(jié)束通話后自動(dòng)返回到應(yīng)用:

 

  1. UIWebView*callWebview =[[UIWebView alloc] init];  
  2.     NSURL *telURL =[NSURL URLWithString:@"tel:10086"];// 貌似tel:// 或者 tel: 都行  
  3.     [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];  
  4.     //記得添加到view上  
  5.     [self.view addSubview:callWebview];  

11 調(diào)用 SMS發(fā)短信: 

 

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://15315310992"]]; 

 

 

12 調(diào)用自帶 瀏覽器 safari 

 

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.baidu.com"]]; 

 

 

13 在一個(gè)程序里打開另一個(gè)程序: 

 

首先:plist里添加URL types   點(diǎn)開里邊的Item0  添加URLSchemes  打開Item0 輸入sinaWeibo 

 

然后在需要調(diào)用的地方:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sinaWeibo://*"]];

 

https://itunes.apple.com/cn/app/qq-2012/id444934666?mt=8

 

14 雙引號(hào)轉(zhuǎn)義: 

 

用 \" 表示 雙引號(hào)

 

15 設(shè)置按鈕按下?lián)Q圖片 松開還是原圖

 

  1. //                [danxuan setImage:[UIImage imageNamed:@"exercise_option_n.png"] forState:UIControlStateNormal];  
  2.                 //這個(gè)是設(shè)置按下的圖片,松開就是上面的圖片  
  3. //               [danxuan setImage:[UIImage imageNamed:@"exercise_option_s.png"] forState:UIControlEventTouchDragOutside];  

16  判斷數(shù)組中是否存在某元素: 

 

BOOL isValue=[keyArray containsObject:@"aaa"];

 

17 Nav添加button

 

  1. UIButton *btnBack = [ABUtil createNavigationCtrollerRoundedRectBtn:Localized(@"取消")];  
  2.     [btnBack addTarget:self  
  3.                 action:@selector(tapLeftBarButton)  
  4.       forControlEvents:UIControlEventTouchUpInside];  
  5.     UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnBack];  
  6.     self.navigationItem.leftBarButtonItem = leftBarButtonItem;  
  7.     [btnBack release];  
  8.     [leftBarButtonItem release] 

本文鏈接:http://www.cnblogs.com/lovewx/archive/2014/08/04/3890664.html

責(zé)任編輯:chenqingxiang 來源: cnblogs
相關(guān)推薦

2013-04-11 16:08:50

iOS開發(fā)技巧積累

2011-08-08 17:05:02

XCode UserScript 腳本

2012-01-18 13:46:37

ARCiOS

2013-12-17 11:04:10

iOS開發(fā)傳感器

2013-06-20 11:04:46

iOS技巧NotificatioBadgeView

2013-07-29 05:01:31

iOS開發(fā)iOS開發(fā)學(xué)習(xí)按鈕拖動(dòng)和點(diǎn)擊

2012-03-06 10:17:45

iOS SQLite3iOSSQLite3

2013-12-17 15:32:20

iOS開發(fā)NewsstandKi

2014-07-21 14:49:35

iOSUILabel

2015-07-20 09:16:42

iOSWatchKit開發(fā)

2014-07-23 13:17:53

iOSUITextField

2011-08-12 08:56:31

JavaScript

2009-08-05 18:32:28

HtmlTextWriASP.NET控件開發(fā)

2009-08-06 17:15:34

C#開發(fā)和使用

2015-08-27 11:16:14

ios開發(fā)技巧

2017-02-15 09:25:36

iOS開發(fā)MQTT

2011-08-02 11:07:42

iOS開發(fā) UIWebView

2011-08-11 16:50:04

iOSTwitter

2017-12-23 14:38:41

Android編程開發(fā)優(yōu)化

2022-09-26 00:00:01

java代碼開發(fā)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)