Time of Update: 2013-12-10
[cpp] //獲得某個window的某個subView UIView *view = [[[[[UIApplication sharedApplication] windows] objectAtIndex:0] subviews] lastObject]; NSInteger index = 0;//用來給儲存的png命名 for (UIView *subView in [view subviews])
Time of Update: 2013-12-10
在設計模式中有一個“單例模式”,對應的我們常常會設計“單例類”(或稱單件類)。但在實際應用中,我們常常也需要使用“半單例”。下面我們具體談談單例和半單例,以及他們的用法和區別。單例模式單例模式(singleton)顧名思義,就是只有一個執行個體。作為對象的建立模式[GOF95],
Time of Update: 2013-12-10
在輸入東西的時候,如果想限制最大字數,可以用下面方法:- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ if ([string
Time of Update: 2013-12-10
服務端說明 #include <errno.h> //一些錯誤資訊的處理#include <stdio.h> // 標準輸入輸出#include <sys/types.h> &
Time of Update: 2013-12-10
使用控制器和視圖Model 應用程式的核心 負責計算與建立一個虛擬世界,它不依靠View與Controller就能存在。(一個沒有外觀介面的應用程式)Controller在Xcode通常是指View
Time of Update: 2013-12-10
今天遇到一問題,折騰很久總算搞明白了 問題是:controllerA和controllerB, 點擊controllerA中的某個按鈕,將controllerB
Time of Update: 2013-12-10
斌子剛剛接觸IOS今天做項目的時候,遇到一個問題,在跳頁時需要進行傳參數。上網找了許多方法,書上也沒有找到很好的方法。所有功能都得自己慢慢摸索。最後找到了一個網友的文章,現在用delegate的方式來實現,實際上delegate傳值的實質就是:比如右AB兩個頁面,A想要傳值給B ,就只要先在A中得到B的指標,然後將想要傳的值賦給B,之後跳轉,話不多說直接上代碼。首先我們需要建一個delegate:[plain] @protocol PassValueDelegate -
Time of Update: 2013-12-10
[plain] #import <Foundation/Foundation.h> @interface CacheHelper : NSObject { } + (void) setObject:(NSData *) data forKey:(NSString *) key withExpires:(int) expires; +
Time of Update: 2013-12-10
[cpp] [cpp] (CGRect)getFrameSizeForImage:(UIImage *)image inImageView:(UIImageView *)imageView { float hfactor = image.size.width / imageView.frame.size.width; float
Time of Update: 2013-12-10
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10,100,300,150)]; label.text = @"Hello world!"; //背景顏色為紅色 label.backgroundColor =
Time of Update: 2013-12-10
括弧配對問題描述現在,有一行括弧序列,請你檢查這行括弧是否配對。輸入第一行輸入一個數N(0<N<=100),表示有N組測試資料。後面的N行輸入多組輸入資料,每組輸入資料都是一個字串S(S的長度小於10000,且S不是空串),測試資料群組數少於5組。資料保證S中只含有"[","]","(",")"四種字元輸出每組輸入資料的輸出佔一行,如果該字串中所含的括弧是配對的,則輸出Yes,如果不配對則輸出No範例輸入
Time of Update: 2013-12-10
AVSystemController *av = [AVSystemController sharedAVSystemController];[av setVolumeTo:0.0
Time of Update: 2013-12-10
//畫圖-(void)addSecondZone:(UIView*)contentView//按鈕圖片UIImage *selecticonNo =[UIImage imageNamed:SelecticonNo];UIImage *selecticon =[UIImage imageNamed:Selecticon]; UIView
Time of Update: 2013-12-10
在自訂協議的標頭檔 .h中@protocol NSDelegate <NSObject>@optional //可選- (void)OnOption:(NSString *)pStr;@required //必須- (void)OnRequired:(NSString *)pStr;@end @interface NSClass :NSObjectid<BSDelegate> delegate;@end @property(assian)
Time of Update: 2013-12-10
1 前言UILabel可以給使用者顯示靜態文字,並且設定文字的樣式。2 代碼執行個體ZYViewController.h: [plain]#import <UIKit/UIKit.h> @interface ZYViewController : UIViewController @property(nonatomic,strong) UILabel *myLabel; @end #import
Time of Update: 2013-12-10
iCloud文檔在儲存的過程中難免會發生衝突,我們必須要有一套解決衝突的策略。策略的採用要根據使用者的需求而定,有的簡單有的複雜,最簡單的是直接使用目前的版本覆蓋衝突版本。複雜的策略,例如:如果是兩個文字檔衝突,可以將兩個衝突點列出來,讓使用者來判斷再進行儲存。我們採用的策略是使用目前的版本覆蓋以前的版本。解決衝突首先需要在updateUbiquitousDocuments:方法中註冊UIDocumentStateChangedNotification通知:[cpp]//當iCloud中的檔案變
Time of Update: 2013-12-10
CGFloat :表示一個浮點CGPoint:表示一個點CGsize:標示一個矩形,但只有高度和寬度CGRect:表示一個矩形,並且有原點的位置。CGRectZero:是一個高度為零,寬度為零,原點位置也為零,需要建立邊框但還不確定邊框大小和位置時,可以使用此常量CGPointMake,CGRectMake,CGSizeMake 用來初始化NSStringFromPoint,NSStringFromRect,NSStringFromSize
Time of Update: 2013-12-10
可以通過子類化按鈕來定製屬於你自己的按鈕類。在子類化的時候你可以重載下面這些方法,這些方法返回CGRect結構,指明了按鈕每一組成部分的邊界。注意:不要直接調用這些方法, 這些方法是你寫給系統調用的。 // these return the rectangle for the background (assumes bounds), the content (image + title) and for the image and title separately. the
Time of Update: 2013-12-10
1 前言UILongPressGestureRecognizer 用來監聽並捕獲到使用者用手指長久按住螢幕的某一個地方的手勢事件。2 代碼執行個體ZYViewController.m [plain]- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor];&
Time of Update: 2013-12-10
1 前言使用 CGAffineTransformMakeScale/CGContextScaleCTM 函數建立一個仿射縮放變換。2 代碼執行個體ZYViewControllerView.m [plain]- (void)drawRect:(CGRect)rect{ CGMutablePathRef path = CGPathCreateMutable(); CGRect