好久沒發表文章了,來篇iOS開發知識整理!

來源:互聯網
上載者:User

2.簡要介紹下記憶體管理機制?

 Cocoa中提供了一個機制來實現上面提到的這個邏輯模型,它被稱為“引用計數”(referring counting)或“保留計數”(retain counting):

3.objc中的減號和加號的意思以及用法?

①減號表示一個函數、或者方法或者訊息的開始(在一個類的執行個體上被調用和實施)(可以認為是私人方法)

②加號表示其他的函數可以直接調用這個類中的方法,而不用建立這個類的執行個體(俗稱靜態方法)

4、項目整理

按鈕:

BtnWinWin = [UIButton buttonWithType: UIControlStateNormal];

BtnWinWin.frame = CGRectMake(768, 679, 256, 42);

[BtnWinWin setBackgroundImage:[UIImage imageNamed:@"btnwinwin.jpg"] forState:UIControlStateNormal];

[BtnWinWin addTarget:self action:@selector(WinWin) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:BtnWinWin];

 

播放器:

NSString *soundPath = [[NSBundle mainBundle]pathForResource:musicTop ofType:@"mp3"];

NSURL *soundURL = [[NSURL alloc]initFileURLWithPath:soundPath];

player = [[AVAudioPlayer alloc]initWithContentsOfURL:soundURL error:nil];

[player setDelegate:self];

[player play];


兩個控制器之間的動畫轉換:

mainFrame = [[Test_Book1_2_Classes_ViewControlleralloc] init];

haveMainFram =TRUE;

CATransition *transition = [CATransitionanimation];

    transition.duration = 1.0f;         /* 間隔時間*/

    transition.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]; /* 動畫的開始與結束的快慢*/

    transition.type = @"pageCurl"; 

    transition.subtype = kCATransitionFromTop;   /* 動畫方向*/

    transition.delegate = self;

    [self.navigationController.view.layeraddAnimation:transition forKey:nil];

[self.navigationControllerpushViewController:mainFrameanimated:YES];

 

sdk相關:

1、兩個.a靜態庫的合并,靜態庫有分適合模擬器的和真機的,如何合并請看:我的另一篇文章http://www.cnblogs.com/visen-0/archive/2011/08/02/2125067.html

2、建立root許可權應用:http://www.cnblogs.com/visen-0/archive/2011/08/22/2149014.html

3、擷取已經安裝的列表:http://www.cnblogs.com/visen-0/archive/2011/08/22/2148847.html

4、自製.ipa檔案下載安裝。

5、判斷是否越獄,去[NSFileManager defaultManager]找是否有對應的比如Cydia.app程式。

 

給伺服器提交資訊:

// 裝置資訊

UIDevice *device = [UIDevice currentDevice];

NSString *identifier = [[NSStringstringWithString:[device uniqueIdentifier]] lowercaseString];

NSLog(@"%@",identifier);

NSString *requestString = [NSStringstringWithFormat:@"http://www.yrwang.net/post.aspx?client=ios&deviceId=%@&reportMessage=%@",identifier,opinion.text];

 

NSString *requestStringUTF8 = [requestString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

 

NSURL * myURL = [[NSURL alloc] initWithString:requestStringUTF8];

NSMutableURLRequest *myRequest = [NSMutableURLRequestrequestWithURL: myURL

cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData

timeoutInterval: 30];

[myURL release];

 

connection_ = [[NSURLConnectionalloc] initWithRequest: myRequest delegate: self];


解析xml:

NSXMLParser* xmlRead = [[NSXMLParser alloc] initWithData:data];//初始化NSXMLParser對象  

[data release]; 

[xmlRead setDelegate:self];

[xmlRead parse];


監聽者模式:

[[NSNotificationCenterdefaultCenter] addObserver:self 

selector:@selector(getUpdatedPoints:) 

name:111 

  object:nil];

[[NSNotificationCenterdefaultCenter] postNotificationName:111 object:nil];


單例模式:

static AdPublisherConnect *sharedInstance_ = nil; 

+ (AdPublisherConnect*)sharedAdPublisherConnect

{

if(!sharedInstance_)

{

sharedInstance_ = [[superalloc] init];

}

 

returnsharedInstance_;

}


檔案的讀取寫,建立:
這個是建立的例子:

//建立檔案管理工具 

NSFileManager *fileManager = [NSFileManagerdefaultManager]; 

//擷取路徑 

//參數NSDocumentDirectory要擷取那種路徑 

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 

NSString *documentsDirectory = [paths objectAtIndex:0];//去處需要的路徑    

//更改到待操作的目錄下 

[fileManager changeCurrentDirectoryPath:[documentsDirectory stringByExpandingTildeInPath]]; 

//建立檔案fileName檔案名稱,contents檔案的內容,如果開始沒有內容可以設定為nil,attributes檔案的屬性,初始為nil 

//擷取檔案路徑 

NSString *path = [documentsDirectory stringByAppendingPathComponent:fileName]; 

 

//建立資料緩衝

NSMutableData *writer = [[NSMutableDataalloc] init]; 

//將字串添加到緩衝中 

[writer appendData:[contents dataUsingEncoding:NSUTF8StringEncoding]]; 

//將其他資料添加到緩衝中 

//將緩衝的資料寫入到檔案中 

[writer writeToFile:path atomically:YES]; 

[writer release]; 

 

字串的擷取某個操作:NSRange

 e = [tempString rangeOfString:@","];

            key = [tempString substringToIndex:e.location];

 

e = [tempString rangeOfString:@"\r\n"];

            tempString = [tempString substringFromIndex:e.location+1];

 

錄音:

AVAudioSession

分頁:
uitable分頁

尋找檔案目錄;

+ (NSMutableArray *)findFile{

NSFileManager *fileManager = [[NSFileManager defaultManager] init];  

    NSMutableArray *everyTitle = [[NSMutableArray alloc] init];  

    NSArray *filePaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);  

    NSString *filePath = [filePaths objectAtIndex:0];  

 

NSLog(@"%@",filePath);  

    NSDirectoryEnumerator *direnum = [fileManager enumeratorAtPath:filePath];   

    NSString *fileName;  

    while ((fileName = [direnum nextObject])) {  

[everyTitle addObject:fileName];  

    } 

 

return everyTitle;

}

 

表單:

UIActionSheet

 

長按按鈕:

UILongPressGestureRecognizer

 

滾動視圖:

UIScrollView

 

web網頁:

UIWebView

 

隱藏導覽列,應用全屏。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.