偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

淺談iPhone開發(fā)常用代碼列舉

移動開發(fā) iOS
本文介紹的是淺談iPhone開發(fā)常用代碼列舉,主要介紹了iphone開發(fā)中常用的代碼,先來看內(nèi)容詳解。

淺談iPhone開發(fā)常用代碼列舉是本文要介紹的內(nèi)容,詳細(xì)的講述了iphone開發(fā)中一些常用的內(nèi)容,不多說,先來看內(nèi)容詳解吧。

UIEdgeInsets 設(shè)置包圍tableView的坐標(biāo)

  1. typedef struct UIEdgeInsets {  
  2.     CGFloat top, left, bottom, right;  // specify amount to inset (positive) for each of the edges. values can be negative to 'outset'  
  3. } UIEdgeInsets; 

里面分別是上,左,下,右的包圍長度,往下拖動時,如果top 》 0, 就會顯示出來,如果小于0就會隱藏。

計算字符串的顯示長度

  1. CGSize detailSize = [@"你的字符串" sizeWithFont:[UIFont systemFontOfSize:15] 
  2. constrainedToSize:CGSizeMake(200, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap]; 

navigationbar的back鍵觸發(fā)其他事件

  1. UIButton *back =[[UIButton alloc] initWithFrame:CGRectMake(200, 25, 63, 30)];  
  2. [back addTarget:self act   
  3. ion:@selector(reloadRowData:) forControlEvents:UIControlEventTouchUpInside];  
  4. [back setImage:[UIImage imageNamed:@"返回按鈕.png"] forState:UIControlStateNormal];  
  5. UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:back];  
  6. self.navigationItem.leftBarButtonItem = loginButtonItem 
  7. [back release];  
  8. [backButtonItem release]; 

防止屏幕暗掉鎖屏

  1. [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; 

顯示網(wǎng)絡(luò)活動狀態(tài)指示符

這是在iPhone左上部的狀態(tài)欄顯示的轉(zhuǎn)動的圖標(biāo)指示有背景發(fā)生網(wǎng)絡(luò)的活動。

  1. UIApplication* app = [UIApplication sharedApplication];  
  2. app.networkActivityIndicatorVisible = YES

獲取UUID

  1. [[UIDevice currentDevice] uniqueIdentifier]  
  2.  
  3. UIDevice *myDevice = [UIDevice currentDevice];  
  4. NSString *deviceID = [myDevice uniqueIdentifier]; 

截取屏幕圖片

  1. UIGraphicsBeginImageContext(CGSizeMake(200,400));  //創(chuàng)建一個基于位圖的圖形上下文并指定大小為CGSizeMake(200,400)  
  2. [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];  //renderInContext 呈現(xiàn)接受者及其子范圍到指定的上下文  
  3.  UIImage *aImage = UIGraphicsGetImageFromCurrentImageContext(); //返回一個基于當(dāng)前圖形上下文的圖片  
  4. UIGraphicsEndImageContext();   //移除棧頂?shù)幕诋?dāng)前位圖的圖形上下文  
  5. imageData = UIImagePNGRepresentation(aImage); //以png格式返回指定圖片的數(shù)據(jù) 

應(yīng)用程序邊框大小

我們應(yīng)該使用"bounds"來獲得應(yīng)用程序邊框。不是用"applicationFrame"。"applicationFrame"還包含了一個20像素的status bar。除非我們需要那額外的20像素的status bar。

震動和聲音播放

 

  1. Sound will work in the Simulator, however some sound (such as looped) has been 
  2. reported as not working in Simulator or even altogether depending on the audio format.
  3.  Note there are specific filetypes that must be used (.wav in this example). 
  1. AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);  
  2. SystemSoundID pmph;  
  3. id sndpath = [NSBundle mainBundle] pathForResource:@"mySound"   ofType:@"wav"  inDirectory:@"/"];  
  4. CFURLRef baseURL = (CFURLRef) [NSURL alloc] initFileURLWithPath:sndpath];  
  5. AudioServicesCreateSystemSoundID (baseURL, &pmph);  
  6. AudioServicesPlaySystemSound(pmph);      
  7. [baseURL release]; 

Iphone獲取本機(jī)IP

  1. -(NSString *)getAddress {  
  2.     char iphone_ip[255];  
  3.     strcpy(iphone_ip,"127.0.0.1"); // if everything fails  
  4.     NSHost* myhost =[NSHost currentHost];  
  5.     if (myhost)  
  6.     {  
  7.         NSString *ad = [myhost address];  
  8.         if (ad)  
  9.             strcpy(iphone_ip,[ad cStringUsingEncoding:NSASCIIStringEncoding]);  
  10.     }  
  11.     return [NSString stringWithFormat:@"%s",iphone_ip];  

小結(jié):淺談iPhone開發(fā)常用代碼列舉的內(nèi)容介紹完了,希望本文對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-08-22 14:31:53

iPhone開發(fā)

2011-08-09 14:54:29

iPhoneNSDateanotherDate

2011-07-08 16:43:46

iPhone Cocoa 多線程

2011-07-08 17:57:37

iPhone CoreData 數(shù)據(jù)庫

2010-04-07 11:21:28

Oracle常用命令

2011-08-16 10:45:25

iPhone開發(fā)控件

2010-01-18 13:42:51

C++代碼

2010-05-12 18:10:26

MySQL出錯代碼

2011-07-27 11:19:33

iPhone UITableVie

2011-08-08 15:05:50

iPhone 網(wǎng)站

2010-04-13 15:24:25

Oracle維護(hù)常用語

2011-07-25 14:44:41

iPhone iPhone開發(fā) 截屏

2012-03-06 16:57:40

jQuery mobijQuery mobiframework

2018-05-10 15:35:03

前端代碼圖像

2011-07-06 17:53:40

iPhone SDK Xcode

2011-08-01 15:17:17

iPhone開發(fā) 證書 簽名

2011-08-01 13:13:19

iPhone開發(fā) 圖片

2011-08-15 11:23:41

iPhone開發(fā)循環(huán)滾動UIScrollVie

2010-08-31 14:01:23

iPhone

2011-08-11 11:51:07

iPhone鍵盤
點(diǎn)贊
收藏

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