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

iPhone開發(fā)知識總結(jié) 上篇

移動開發(fā) iOS
iPhone開發(fā)知識總結(jié) 上篇是本文要介紹的內(nèi)容,主要講述的是iphone應用開發(fā)中Atomic 和 nonatomic 屬性的理解,來看詳細內(nèi)容。

iPhone開發(fā)知識總結(jié) 上篇是本文要介紹的內(nèi)容,主要講述的是iphone開發(fā)應用中Atomic nonatomic 屬性的理解,來看詳細內(nèi)容。

1、關(guān)于不同分辨率的屏幕顯示問題 
 
iphone 3 和 4分辨率各不相同。加載圖像的時候只需要指定基本的文件名,例如:pic.png根據(jù)不同分辨率,如果在iphone 4 上會自動加載pic@2x.png(如果存在)。

2、關(guān)于Atomic 和 nonatomic 屬性的理解

atomic的訪問控制器只用在沒有垃圾回收的環(huán)境中。

使用atiomic能保證線程安全的,保證一個屬性的get/set在一個線程中必須完成之后才能有其他的線程訪問它。

  1. //@property(nonatomic, retain) UITextField *userName;  
  2. //Generates roughly   
  3. - (UITextField *) userName {  
  4.     return userName;  
  5.   }   
  6. - (void) setUserName:(UITextField *)userName_ {  
  7.     [userName_ retain];      
  8.     [userName release];     
  9.     userName = userName_;  
  10.  }  

Now, the atomic variant is a bit more complicates:

  1. //@property(retain) UITextField *userName;  
  2. //Generates roughly   
  3. - (UITextField *) userName {  
  4.     UITextField *retval = nil;      
  5.   @synchronized(self) {  
  6.           retval = [[userName retain] autorelease];  
  7.    }     
  8.     return retval;  
  9.  }   
  10. - (void) setUserName:(UITextField *)userName_ {    
  11.      @synchronized(self) {       
  12.      [userName_ retain];        
  13.      [userName release];       
  14.       userName = userName_;   
  15. }  
  16.   

Atomic版本加了一個鎖保證線程安全的,atomic保證userName方法獲得的不是一個釋放過的值。

3、使用歸檔程序復制對象(深復制)

  1. NSMutableArray *dataArray = [NSMutableArray arrayWithObjects:[NSMutableString stringWithString: @"one"], ....];  
  2. NSMutableArray *dataArray2;  
  3.  
  4. NSData data = [NSKeyedArchiver archivedDataWithRootObject:dataArray];  
  5. dataArray2 = [NSKeyedUnarchiver unarchiveObjectWithData: data]; 

4、在iphone開發(fā)中,設置navigationController中返回按鈕的標題,默認為前一個視圖中標題的title,

如果設置,在前一個視圖中寫下:

  1. UIBarButtonItem *temporaryBarButtonItem=[[UIBarButtonItem alloc] init];  
  2. temporaryBarButtonItem.title=@"Back";  
  3. self.navigationItem.backBarButtonItem = temporaryBarButtonItem;  
  4. [temporaryBarButtonItem release]; 

5、在table view 中加入手勢或者事件觸摸機制,需要實現(xiàn)方法

  1. -(BOOL)canBecomeFirstResponder {  
  2. return YES;  

應該如下判斷用戶觸摸的是哪一個cell

  1. CGPoint pinchLocation = [pinchRecognizer locationInView:self.tableView];  
  2.  
  3. NSIndexPath *newPinchedIndexPath = [self.tableView indexPathForRowAtPoint:pinchLocation]; 

6、- (void)dismissModalViewControllerAnimated:(BOOL)animated

UIViewController的這個方法很有意思,一般parent view controller都有責任調(diào)用此方法來消除其通過presentModalViewController:animated: 方法展現(xiàn)的modal view controller。但是如果你在modal view controller中調(diào)用此方法,modal view controller會自動的把此消息轉(zhuǎn)發(fā)給parent view controller。

小結(jié):iPhone開發(fā)知識總結(jié) 上篇的內(nèi)容介紹完了,如果你對iphone開發(fā)感興趣的話,請參考 iPhone開發(fā)知識總結(jié) 下篇的相關(guān)內(nèi)容,***希望本文能對你有所幫助!

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

2011-08-15 10:45:11

iPhone開發(fā)delegate

2011-07-19 09:46:38

2011-08-11 10:16:23

iPhoneUIView視圖

2011-08-04 16:17:39

iPhone 開發(fā)工具

2021-06-26 10:03:35

Python框架Flask

2009-01-11 09:14:45

Javascript開發(fā)總結(jié)

2020-04-22 13:33:30

iPhone蘋果3C制造業(yè)

2021-08-23 10:12:41

鴻蒙HarmonyOS應用

2012-05-17 11:45:12

iPhone

2011-07-19 10:42:41

iPhone 應用程序 模型

2013-01-06 09:52:43

SQLite

2013-04-09 16:04:06

iOS開發(fā)SQLite知識總結(jié)

2021-08-26 10:25:04

JavaScript進階操作 前端

2012-04-26 21:56:59

iPhone

2011-08-11 11:37:34

iPhone內(nèi)存

2011-07-06 17:53:40

iPhone SDK Xcode

2021-04-12 10:00:47

Sqlite數(shù)據(jù)庫CMD

2011-06-17 16:47:12

Qt Eclipse Windows

2011-08-02 17:14:41

iPhone應用 UITableVie

2014-06-10 13:44:58

iOSUIImage知識點
點贊
收藏

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