日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iPhone开发中的一些小技巧

發布時間:2025/3/20 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iPhone开发中的一些小技巧 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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"]; 轉自:cocoachina

轉載于:https://www.cnblogs.com/liuxingzi/archive/2012/11/16/3404259.html

總結

以上是生活随笔為你收集整理的iPhone开发中的一些小技巧的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。