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

iPhone學習筆記幾個實例開發(fā)操作

移動開發(fā) iOS
本文介紹的是iphone應(yīng)用中幾個小結(jié)實例開發(fā),很簡單的實現(xiàn)了他們的功能,先來看詳細內(nèi)容。

iPhone學習筆記幾個實例開發(fā)操作是本文要介紹的內(nèi)容,主要有ios震動、NSUserDefaults用法、如何讀取文件等內(nèi)容,來看本文內(nèi)容。

IOS震動

震動是聲音的一種,用如下方式:

  1. #import <AudioToolbox/AudioToolbox.h>   
  2. #import <UIKit/UIKit.h>   
  3. - (void)vibrate   
  4. {   
  5.     AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);   
  6. }  

調(diào)用到震動器震動。

iPhone中定時器NSTimer使用方法

  1. - (void) applicationDidFinishLaunching: {  
  2. NSTimer *_timer = [[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(onTimer) userInfo:nil repeats:YES] retain];  
  3. }  
  4. // call function when time is up (in this exemple :1 second. to change it, change scheduledTimerWithTimeInterval: 1 to value in second)  
  5. - (void)onTimer  
  6. {  
  7. // schedule code..  

NSUserDefaults用法

  1. -(void)saveToUserDefaults:(NSString*)myString   
  2. {   
  3. NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];   
  4. if (standardUserDefaults)        
  5. {   
  6. [standardUserDefaults setObject:myString forKey:@"Prefs"];   
  7.        [standardUserDefaults synchronize];  
  8.      }   
  9. }     
  10. -(NSString*)retrieveFromUserDefaults   
  11. {   
  12. NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];    
  13. NSString *val = nil;   
  14. if (standardUserDefaults)         
  15. val = [standardUserDefaults objectForKey:@"Prefs"];   
  16. return val;   

iPhone中如何從Application Bundle中讀取文件

首先必須將文件加入Xcode工程的Resources目錄。然后可以如下訪問文件,假設(shè)文件為MyFile.txt:

  1. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyFile" ofType:@"txt"];       
  2.  
  3. NSData *myData = [NSData dataWithContentsOfFile:filePath];       
  4.  if (myData) {       
  5.     // do something useful       
  6.  }  

一段將help文本文件讀入UIWebView的完整示例:

  1. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"HelpDoc" ofType:@"htm"];       
  2.  NSData *htmlData = [NSData dataWithContentsOfFile:filePath];       
  3.  if (htmlData) {       
  4.      [webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@"http://iphoneincubator.com"]];       
  5.  }  

如果想將文件讀入字符串,則可以用UITextView顯示,例如:

  1. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"important" ofType:@"txt"];    
  2.  if (filePath) {    
  3.     NSString *myText = [NSString stringWithContentsOfFile:filePath];    
  4.      if (myText) {    
  5.          textView.textmyText;    
  6.     }    
  7.  }  

小結(jié):iPhone學習筆記幾個實例開發(fā)操作的內(nèi)容介紹完了,希望通過本文的學習對你有所幫助!

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

2011-08-15 10:06:22

iPhone開發(fā)nib 文件

2011-08-09 17:29:29

iPhone文件屏幕

2011-08-08 14:57:46

iPhone Autoreleas Property

2011-07-07 16:42:38

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

2011-08-03 16:01:24

iPhone應(yīng)用開發(fā) 自動登陸

2011-07-25 18:02:51

iPhone LibFetion 移植

2011-08-12 09:48:24

iPhoneCoreLocatio定位

2011-08-19 11:10:31

iPhone應(yīng)用

2011-08-08 16:56:44

iPhone 字符處理 視圖

2011-07-18 13:37:53

2011-07-26 11:13:15

iPhone PXL

2011-08-16 18:13:42

IPhone開發(fā)UIView動畫

2011-08-19 09:49:03

iPhone開發(fā)Three20 NetTTRequestLo

2011-07-18 17:52:47

Linux iPhone

2011-07-27 17:07:06

iPhone 游戲 Cocos2d

2011-08-22 13:46:15

iPhone開發(fā)GameKit 藍牙

2011-08-08 10:10:14

iPhone開發(fā) 圖片 方法

2011-08-01 18:27:58

iPhone開發(fā) UISearchBa

2011-08-19 10:13:05

iPhone開發(fā)

2011-07-27 11:19:33

iPhone UITableVie
點贊
收藏

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