国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

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

2019-11-14 20:09:08
字體:
供稿:網(wǎng)友

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 : 
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 默認(rèn)選中tabbar為第一個(gè)view: 
TabBarController.selectedIndex= 0; 


其他: 
8 已知兩地經(jīng)緯度 計(jì)算兩地之間的距離: 
//    地圖顯示當(dāng)前位置: 
    mapView.showsUserLocation=YES; 
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];//創(chuàng)建位置管理器 
    locationManager.delegate=self;//設(shè)置代理 
    locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度級別為最佳精度 
    locationManager.distanceFilter=1000.0f;//設(shè)置距離篩選器為任何移動(dòng)都要發(fā)送更新 
    [locationManager startUpdatingLocation];//啟動(dòng)位置管理器 
    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); 
    
//   已知兩點(diǎn)的經(jīng)緯度,計(jì)算出兩地距離: 
    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 取小數(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)用: 
UIWebView*callWebview =[[UIWebView alloc] init]; 
    NSURL *telURL =[NSURL URLWithString:@"tel:10086"];// 貌似tel:// 或者 tel: 都行 
    [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; 
    //記得添加到view上 
    [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 雙引號轉(zhuǎn)義: 
用 /" 表示 雙引號 

15 設(shè)置按鈕按下?lián)Q圖片 松開還是原圖 
//                [danxuan setImage:[UIImage imageNamed:@"exercise_option_n.png"] forState:UIControlStateNormal]; 
                //這個(gè)是設(shè)置按下的圖片,松開就是上面的圖片 
//               [danxuan setImage:[UIImage imageNamed:@"exercise_option_s.png"] forState:UIControlEventTouchDragOutside]; 

16  判斷數(shù)組中是否存在某元素: 
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]


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 儋州市| 余江县| 洞口县| 自治县| 昌都县| 璧山县| 横山县| 新郑市| 台南县| 石阡县| 奇台县| 北票市| 民勤县| 平乡县| 绍兴市| 双牌县| 阳春市| 南木林县| 新绛县| 安国市| 三门峡市| 托克逊县| 莎车县| 临朐县| 德令哈市| 长宁县| 甘南县| 阳原县| 平远县| 泗洪县| 桓仁| 辉县市| 洛扎县| 永昌县| 绵竹市| 仁怀市| 论坛| 仁化县| 宽甸| 兰溪市| 固镇县|