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

iPhone應(yīng)用開發(fā)學(xué)習(xí)筆記

移動開發(fā) iOS
本文主要講解了iphone如何讀取txt文件、利用WebView在ipad下實(shí)現(xiàn)滾動分頁效果、iPhone抓圖程序的內(nèi)容,來看詳細(xì)內(nèi)容。

iPhone應(yīng)用開發(fā)學(xué)習(xí)筆記是本文要介紹的內(nèi)容,主要講解了iphone如何讀取txt文件、利用WebView在ipad下實(shí)現(xiàn)滾動分頁效果、iPhone抓圖程序的內(nèi)容,來看詳細(xì)內(nèi)容。

iphone讀取txt文件

讀取一般性文檔文件 

  1. NSString *tmp;   
  2. NSArray *lines;    
  3. lines = [[NSString    stringWithContentsOfFile:@"testFileReadLines.txt"]   
  4.               componentsSeparatedByString:@"\n"];   
  5.  
  6. NSEnumerator *nse = [lines objectEnumerator];   
  7.  
  8. // 讀取<>里的內(nèi)容   
  9. while(tmp = [nse nextObject]) {   
  10.           NSString *stringBetweenBrackets = nil;   
  11.           NSScanner *scanner = [NSScanner scannerWithString:tmp];   
  12.           [scanner scanUpToString:@"<" intoString:nil];   
  13.           [scanner scanString:@"<" intoString:nil];   
  14.           [scanner scanUpToString:@">" intoString:&stringBetweenBrackets];   
  15.  
  16.           NSLog([stringBetweenBrackets description]);   
  17.   }  

利用WebView在ipad下實(shí)現(xiàn)滾動分頁效果

WebView里面的網(wǎng)頁,滾動的時(shí)候默認(rèn)是平滑滾動的,如果需要讓它實(shí)現(xiàn)分頁的滾動效果,那么如何做?

默認(rèn)UIWebView是沒有API提供的,但是在sdk3.2下,它的***個(gè)子View是UIScrollView(注意對于3.2之下的版本是UIScroller一個(gè)私有未公開的,這個(gè)暫時(shí)沒研究如何設(shè)置).

代碼相對比較簡單:

  1. int height = webView.frame.size.height;  
  2.  
  3. NSString *html = [NSString stringWithFormat:@"<html><head><style>div{height:%dpx;
  4. }
  5. </style></head><body style='margin:0px'><div style='background-color:#FF0000;'>
  6. </div><div style='background-color:#FFFF00;'></div><div style='background-color:#FF00FF;'>
  7. </div><div style='background-color:#0000FF;'></div><div style='background-color:#00FFFF;'>
  8. </div><div style='background-color:#00FF00;'></div></body></html>",  
  9.   height];  
  10.  
  11. [webView loadHTMLString:html baseURL:nil];  
  12. UIScrollView *scrollView = [webView.subviews objectAtIndex:0]; // it is "UIScroller" on iphone(v3.1.3-)  
  13. if (scrollView && [scrollView isKindOfClass:[UIScrollView class]]) {  
  14.     scrollView.pagingEnabled = YES;  
  15. }  

iPhone抓圖程序

//獲得屏幕圖像

  1. - (UIImage *)imageFromView: (UIView *) theView    
  2. {  
  3.       
  4.     UIGraphicsBeginImageContext(theView.frame.size);  
  5.     CGContextRef context = UIGraphicsGetCurrentContext();  
  6.     [theView.layer renderInContext:context];  
  7.     UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();  
  8.     UIGraphicsEndImageContext();  
  9.       
  10.     return theImage;  

//獲得某個(gè)范圍內(nèi)的屏幕圖像

  1. - (UIImage *)imageFromView: (UIView *) theView   atFrame:(CGRect)r  
  2. {  
  3.     UIGraphicsBeginImageContext(theView.frame.size);  
  4.     CGContextRef context = UIGraphicsGetCurrentContext();  
  5.     CGContextSaveGState(context);  
  6.     UIRectClip(r);  
  7.     [theView.layer renderInContext:context];  
  8.     UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();  
  9.     UIGraphicsEndImageContext();  
  10.       
  11.     return  theImage;//[self getImageAreaFromImage:theImage atFrame:r];  

小結(jié):iPhone應(yīng)用開發(fā)學(xué)習(xí)筆記的內(nèi)容介紹完了,希望本文對你有所幫助!

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

2011-08-08 14:57:46

iPhone Autoreleas Property

2011-08-19 11:10:31

iPhone應(yīng)用

2011-08-12 09:48:24

iPhoneCoreLocatio定位

2011-08-15 10:06:22

iPhone開發(fā)nib 文件

2011-08-08 10:10:14

iPhone開發(fā) 圖片 方法

2011-08-05 14:48:06

iPhone應(yīng)用 異步隊(duì)列

2011-08-18 10:39:46

iPhone開發(fā)界面

2011-08-08 15:56:18

iPhone 震動 NSUserDefa

2011-08-09 17:12:30

iPhoneCFRunLoop

2011-08-15 17:38:48

iPhone開發(fā)調(diào)試工具

2011-07-27 11:14:37

iPhone UITableVie

2011-08-15 17:52:21

iPhone應(yīng)用對象NSString

2011-08-15 18:02:32

iPhone開發(fā)表視圖

2011-08-16 18:13:42

IPhone開發(fā)UIView動畫

2011-08-19 09:49:03

iPhone開發(fā)Three20 NetTTRequestLo

2011-07-27 10:13:23

Cocos2D iPhone

2011-07-19 09:46:38

2011-07-08 14:58:16

iPhone Xcode iOS

2011-07-19 09:58:36

2011-08-08 16:56:44

iPhone 字符處理 視圖
點(diǎn)贊
收藏

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