Time of Update: 2014-04-13
今天項目中有個文字框需要只可以輸入數位需求,首先在.xib中將UITextField的Keyboard設定為Number Pad,但是使用時鍵盤會切回別的鍵盤無法對內容進行校正。通過神奇的百度我知道了通過以下方法可以解決這樣的問題:首先讓.xib的viewController實現UITextFieldDelegate然後和想要校正的控制項關聯。然後將下列代碼粘貼到類中即可。- (BOOL)textField:(UITextField *)textField
Time of Update: 2014-04-09
這是一個很有趣的問題,在Car2複製時候,CAR2的引擎複製了幾次?為什嗎?這個問題涉及到深淺複製,屬性的應用,以及記憶體的整理等多方面。結果很有趣,答案是三次。#import #import "Car.h"int main(int argc, const char * argv[]){ @autoreleasepool { Car *car = [[[Car alloc] init] autorelease]; NSLog(@"%@", car);
Time of Update: 2014-04-04
最近蘋果發布了IOS7.1。話說蘋果每次發布都牽動開發人員的心哈,這次讓我們又小糾結了一陣。廢話不多說,說下AdHoc在ios7.1不能下載的原因,就是ios7.1不接受未經ssl驗證的manifest了,就意味著plist檔案的路徑需要從http換為https:itms-services://?action=download-manifest&url=http://domain.com/app.plist==>
Time of Update: 2014-04-02
下面代碼的作用是:當你點擊選中tableview的某一行時,它將記錄被選中的行。當你左掃並刪除某一行時,它將刪除該行資料並更新Uitableview中的資料。@interface DummyTableViewController : UITableViewController@property (nonatomic, strong) NSMutableArray *items;@end@implementation DummyTableViewController- (instancetype)
Time of Update: 2014-03-27
- (UIImage *)fixOrientation:(UIImage *)srcImg { if (srcImg.imageOrientation == UIImageOrientationUp) return srcImg; CGAffineTransform transform = CGAffineTransformIdentity; switch (srcImg.imageOrientation) { case
Time of Update: 2014-03-24
-(void) tapClick:(UITapGestureRecognizer *)tap{ [UIViewbeginAnimations:@"exitApplication"context:nil]; [UIViewsetAnimationDuration:0.5];
Time of Update: 2014-03-27
Phonegap攔截菜單按鍵的事件menubutton,用於處理html5當中的菜單攔截事件此事件是當使用者按下菜單是時候觸發 document.addEventListener("menubutton", yourCallbackFunction, false);支援平台: Amazon Fire OSAndroidBlackBerry 10 簡單例子: document.addEventListener("menubutton", onMenuKeyDown,
Time of Update: 2014-03-22
1.Foundation架構中提供了很多的集合類如:NSArray,NSMutableArray,NSSet,NSMutableSet,NSDictionary,NSMutableDictionary但是這些類只能存放OC物件類型的資料2.如果要存放基礎資料型別 (Elementary Data
Time of Update: 2014-03-23
遇到的問題:以下兩種定製化UIBarButtonItem的代碼在iOS7下沒有問題:[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor darkGrayColor]} forState:UIControlStateNormal];[[UIBarButtonItem
Time of Update: 2014-03-23
使用NavigationViewController進行頁面跳轉時,應該使用pushViewController方法來跳轉至下一頁面,這樣的話,下一頁面同樣在NavigationViewController容器中。1、跳轉到下一頁面:AloneSetPrizeViewController *setPrize = [[AloneSetPrizeViewController alloc]
Time of Update: 2014-03-22
我們先來轉換一個簡單的block代碼: 源:int main() { void (^blk)(void) = ^{printf();}; blk(); return 0; }struct __block_impl { void *isa; int Flags; int Reserved; void *FuncPtr;};struct
Time of Update: 2014-03-22
blocks blocks是c語言的擴充,他是:帶有自動變數(局部變數)的匿名函數。 這個概念叫做:閉包。如python中的lambda,在c++11中也引入了lambda; 維基百科中關於閉包:閉包(Closure)是詞法閉包(Lexical
Time of Update: 2014-03-22
繼續說說ios不同版本之間的適配先說一個東西:在xcode當中有一個東西叫targets,蘋果的官方文檔是這樣說的:A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. A target defines a single product; it organizes the
Time of Update: 2014-03-19
明明可以在本機測試但是卻不能倒出p12認證,認證也無法展開,各位患者請看認證還有效,就是沒有展開的小三角,download重安裝好多次還是這個熊樣,急死活人把。這種情況很可能是keychain放錯了地方,我把所有的菜單都翻了一邊終於找到了這傢伙vcD4KPHA+PGltZyBzcmM9"http://www.2cto.com/uploadfile/Collfiles/20140318/2014031809330593.jpg" alt="\">這裡就有個小三角了,還可以展開然後匯出p12
Time of Update: 2014-03-19
arc automatic reference counting 記憶體管理中對引用採取自動計數。apple官方文檔: 在oc中採用arc機制,讓編譯器來進行記憶體管理,在新一代apple llvm編譯器中設定arc為有效狀態,就無需再次鍵入retain或release代碼,降低程式崩潰,記憶體泄露等風險的同時,很大程度上減少了開發程式的工作量。編譯器完全清楚目標對象,並能立刻釋放那些不再被使用的對象。如此一來,應用程式將具有可預測性,並且能流程運行,運行速度也將大幅提升。來說一下引用計數:
Time of Update: 2014-03-19
地圖類開發應用中,離不開地理位置跟MKMapView的使用,下面就記錄下自己在使用這兩個東西中學到的。 不過並不是所有蘋果的裝置都支援地理位置,我們在使用前應該做個判斷,代碼如下: 1 BOOL locationAvailabe = [CLLocationManager locationServicesEnabled];2 BOOL magnetometerAvailable = [CLLocationManager
Time of Update: 2014-03-12
autorelase:可以將對象交給自動釋放池中,釋放池銷毀的時候對裡面的對象做一次release作業碼如下*person =注意:定義方法名的時候以類名開頭,傳回型別為instancetype,而且在建立對象的時候使用self關鍵字#import <Foundation/Foundation.h>++ (instancetype)personWithAge:( +*person =] init] autorelease]; }+
Time of Update: 2014-03-12
對象執行autorelease方法時會將對象添加到自動釋放池中當自動釋放池銷毀時自動釋放池中所有對象作release操作對象執行autorelease方法後自身引用計數器不會改變,而且會返回對象本身autorelease實際上只是把對release的調用延遲了,對於每一次autorelease系統只是把該對象放入了當前的autorelease
Time of Update: 2014-03-10
內購——在應用程式內購買 (Nonconsumable)買了就有,頭銜,功能(Consumable),買了就用,用了就沒 定義的商品 定義好的商品#define kIAPBomb @"airplay.10bombs"#define kIAPBullet
Time of Update: 2014-03-10
* 裡面有一個程式的入口:main函數 * pch檔案中的內容能被項目中的其他任何檔案分享權限設定\包含\訪問* 如果定義的內容只用在OC環境中,就必須定義在#ifdef __OBJC__和#endif之間 #ifdef DEBUG#define MyLog(...) NSLog(__VA_ARGS__)#else#define MyLog(...)#endif *