Time of Update: 2018-12-05
在用xcode開發的時候偶爾會出現一些好像不應該的錯誤,今天遇到的其實也不算是錯誤,在鍵盤command+滑鼠選擇- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath系統函數的時候不能夠索引,也就是說command滑鼠左鍵點擊關鍵字,曝出了“Symbol not found”這個錯誤.其實這個問題很好解決:主要原因是工程索引檔案損壞, 直接進入~
Time of Update: 2018-12-05
在IOS開發中我們經常用到網路,網路是不可或缺的,有網路連接和沒有網路連接的時候進行不同的處理,斷點續傳等等都離不開網路檢測。今天我自己簡單的做了一個demo,用一個函數封裝網路檢測;-(BOOL)netWorkIsExistence{ struct sockaddr_in initAddress; //sockaddr_in是與sockaddr等價的資料結構 bzero(&initAddress,
Time of Update: 2018-12-05
使用 Search Display Controller 控制項 實現UISearchDisplayDelegate定義全部的table的資料和 過濾後的資料,以及過濾標記@property (strong, nonatomic) NSArray *arOriginal;@property (strong, nonatomic) NSArray *arFiltered;@property (readwrite, nonatomic) BOOL isSearching;在
Time of Update: 2018-12-05
http://stackoverflow.com/questions/150446/how-do-i-detect-when-someone-shakes-an-iphoneAdd/Override canBecomeFirstResponder, viewDidAppear: andviewWillDisappear: methods in your View Controller (這個View
Time of Update: 2018-12-05
以下是我的一些總結,如果有不對的地方希望大家多多指教我們在官方文檔裡看到這樣的代碼:在MyClass.h檔案中@interface MyClass : NSObject { MyObject *myObject; }@property (nonatomic, retain) MyObject *myObject;@end在MyClass.m檔案中@synthesize myObject;-(id)init{if(self = [super init]){MyObject *
Time of Update: 2018-12-05
static Config * instance =nil;+(Config *) Instance { @synchronized(self) { if(nil == instance) { [self new]; } } returninstance;}+(id)allocWithZone:(NSZone *)zone { @synchronized(self) { if(instance
Time of Update: 2018-12-05
在理解CALayer之前需要先瞭解什麼是層。在IOS開發中層是個很重要的概念,在UIView的子類中都可以找到層這個組件,層是位於固定的畫布上的一個子片,可以被覆蓋。層是彼此堆疊在一起的最終產生一個介面。除此之層可以包含多個層,通過層可以操作位於此層上面的其他內容,例如旋轉,動畫,翻頁等。但是如果要訪問UIView類的layer屬性:CALayer *layer =
Time of Update: 2018-12-05
我們都學過位操作,工作中我們用好位操作能夠大大提高程式的效率,簡單介紹一個我的運用的例子:- (void)buttonClick:(id)sender { UIButton *button = (UIButton *)sender; int tag = button.tag; int x = (tag>>8) &0xF; int y = tag & 0x0F; NSLog(@"(%d, %d)", x, y);}-
Time of Update: 2018-12-05
一:首先到https://github.com/facebook/three20/archives/master下載最新版的Three20庫;預設下載路徑是目前使用者下面的下載檔案夾(./Downloads);下載完成以後直接加壓倒Download檔案夾下面: 二:開啟xcode建立基於Empty
Time of Update: 2018-12-05
當你在seachBar中輸入字母之前的時候,只是用滑鼠選中searchBar的時候,終端輸出如下:(這個時候調用先shouldBeginEditing,之後調用didBeginEditing,)當你希望選中UISearchBar的時候,鍵盤自動調用載入到介面,你需要將下面函數的傳回值設定為YES;- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar { NSLog(@"shouldBeginEditing");
Time of Update: 2018-12-05
方法1:使用NSTimer來實現 主要使用的是NSTimer的scheduledTimerWithTimeInterval方法來每1秒執行一次timeFireMethod函數,timeFireMethod進行倒計時的一些操作,完成時把timer給invalidate掉就ok了,代碼如下: secondsCountDown = 60;//60秒倒計時 countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1
Time of Update: 2018-12-05
如何判斷 ios裝置的類型(iphone,ipod,ipad) 功能函數:-(bool)checkDevice:(NSString*)name{NSString* deviceType = [UIDevice currentDevice].model;NSLog(@"deviceType = %@", deviceType);NSRange range =
Time of Update: 2018-12-05
1. 首先,右鍵建立一個 InfoPlist.string的檔案,就是右鍵建立一個newFile,然後resource, 然後選擇String Files類型,這樣就建立了一個string 檔案。 2.接下來,就會發現選中這個檔案,右鍵屬性裡面看到,localize後只能建立一個english的本地化,: 找了半天不知道在哪裡添加其他的本地化檔案,因為一般的都是下面這樣的樣子: 3. 後面發現是在 project 設定的info欄裡面,有個 localizations的地方,可以有+
Time of Update: 2018-12-05
一、第一種建立UISwitch控制項的方法,在代碼中動態建立。1、開啟Xcode 4.3.2, 建立項目Switch,選擇Single View Application。2、開啟ViewController.m檔案在viewDidLoad方法裡添加代碼: - (void)viewDidLoad{ [super viewDidLoad]; UISwitch *switchButton = [[UISwitch alloc] initWithFrame:CGRectMake(50, 1
Time of Update: 2018-12-05
UIActionSheet是在IOS彈出的選擇按鈕項,可以添加多項,並為每項添加點擊事件。為了快速完成這例子,我們開啟Xcode 4.3.2, 先建立一個single view application。然後再xib檔案添加一個button,用來彈出sheet view。1、首先在.h檔案中實現協議,加代碼的地方在@interface那行的最後添加<UIActionSheetDelegate>,協議相當於java裡的介面,實現協議裡的方法。@interface
Time of Update: 2018-12-05
接上篇 iOS學習之iOS沙箱(sandbox)機制和檔案操作(一) 我們看看如何擷取應用程式沙箱目錄。包括真機的沙箱的目錄。 1、擷取程式的Home目錄 NSString *homeDirectory = NSHomeDirectory(); NSLog(@"path:%@", homeDirectory); 列印結果:2012-06-17 14:00:06.098 IosSandbox[3536:f803]
Time of Update: 2018-12-05
接上篇,iOS學習之iOS沙箱(sandbox)機制和檔案操作(二),我們看看NSFileManager如何使用。包括建立檔案,目錄,刪除,遍曆目錄等。 1、在Documents裡建立目錄建立一個叫test的目錄,先找到Documents的目錄, NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString
Time of Update: 2018-12-05
一、動態添加Button動態添加Button的效果就是點擊之後,產生一個按鈕,並為按鈕添加點擊的方法。1、在xib檔案上拖拽添加一個button,標題為:添加button。 2、按住ctrl鍵拖拽到addbuttonViewController.m檔案空白處,產生IBAction,填充代碼後如下:- (IBAction)addButton:(id)sender { CGRect frame = CGRectMake(90, 200, 200, 60); UIButton
Time of Update: 2018-12-05
bundle是一個目錄,其中包含了程式會使用到的資源.這些資源套件含了像,聲音,編譯好的代碼,nib檔案(使用者也會把bundle稱為plug-in).對應bundle,cocoa提供了類NSBundle.我們現在用bundle擷取程式裡的一張圖片,並顯示到View上。 建立一個Single View Application,並在加入viewDidLoad方法裡加入如下代碼: // 通過使用下面的方法得到程式的main bundle NSBundle *mainBundle =
Time of Update: 2018-12-05
iOS學習之UINavigationController詳解與使用(二)頁面切換和segmentedController 接上篇,我們接著講Navigation 的Toolbar。 1、顯示Toolbar 在RootViewController.m的- (void)viewDidLoad方法中添加代碼,這樣Toobar就顯示出來了。 [self.navigationController setToolbarHidden:NO