Time of Update: 2018-12-05
TTURLRequest *request = [TTURLRequestrequestWithURL:url delegate:self]; TTURLDataResponse *response = [[[TTURLDataResponsealloc] init] autorelease];NSString *body = [NSStringstringWithFormat:@"seat=%@&chooseSeat=%@",seat,chooseSeat
Time of Update: 2018-12-05
利用Timer定時器NSTimer *connectionTimer; //timer對象//執行個體化timerself.connectionTimer=[NSTimerscheduledTimerWithTimeInterval:1.5 target:selfselector:@selector(timerFired:) userInfo:nil repeats:NO];[[NSRunLoop currentRunLoop]addTimer:self.connectionTimer
Time of Update: 2018-12-05
MacPorts和Homebrew都是Mac OS X上的軟體包管理工具 (via Wikipedia),且它們之間是不相容的.個中好處就不介紹了,這裡要說的是刪除MacPorts並安裝Homebrew.準備條件:Mac是內建Ruby程式的,如果你之間”處理”過它,記得要確保它的存在.用ruby -v查看下版本號碼.安裝xcode開啟Terminal(終端)刪除MacPorts:#原版使用MacPorts安裝過的軟體在/opt/local目錄下,刪除之前最好查看下,心裡有個數.sudo
Time of Update: 2018-12-05
服務端使用gzip壓縮,可以大幅度減小傳輸包的體積,加快用戶端網路請求速度,為使用者節省流量。當伺服器返回的httpHeader的"Content-Encoding"
Time of Update: 2018-12-05
intmain(intargc,char *argv[]){ @autoreleasepool{ // 異常停在了下面這行,毫無提示作用 returnUIApplicationMain(argc,argv,nil,NSStringFromClass([MyClassclass]));}}XCode的Console介面報出了一些出錯資訊, 如所示:我根據Console裡面的文字提示資訊,猜出應該是出現了null
Time of Update: 2018-12-05
iphone裡如何?像圖片瀏覽那樣的自動隱藏和導航條和工具列呢?其實很簡單,只需要設定toolbar和navigationBar的顯示和隱藏屬性就可以了。如下未隱藏的 隱藏後的 具體實現代碼如下 首先在viewDidLoad裡設定toolBarHidden = NO, 預設是YES(隱藏的),為了讓toolbar顯示,需要設定為NO(不隱藏)。- (void)viewDidLoad { [super viewDidLoad]; self.title = @"隱藏導覽列";
Time of Update: 2018-12-05
在項目開發中,共用代碼是很常見的。由於iOS的限制,我們無法以“動態庫”的形式共用代碼。除了以原始碼方式,我們只能選擇靜態庫來共用代碼。“真架構”項目以編譯後的二進位形式共用代碼,本質上還是一種靜態庫。但由於Xcode的限制(沒有提供相應的項目模板),要以架構的形式編譯出靜態庫,仍然十分麻煩。首先,你需要下載 iOS Universal Framework Mk
Time of Update: 2018-12-05
隨著應用的社交性需求的增加,你的應用也無法避免的要加入好友名單。但好友太多怎麼辦?就需要將好友的名字按拼音來排序。下面我就講一下如何將一個數組中的若干好友的dictionary按名字拼音排序:[_friendObjectArray sortUsingFunction:friendSortFuc context:nil];上面這句代碼會調用一個名為 friendSortFuc的方法來使_friendObjectArray變得有序。下面是這個方法的實現:static NSInteger
Time of Update: 2018-12-05
// 返回顯示的列數- (NSInteger)numberOfComponentsInPickerView:(UIPickerView*)pickerView{ return 3;}// 返回當前列顯示的行數- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{// if (component==0) {// NSMutableArray
Time of Update: 2018-12-05
for (GoldView *vcin viewGoldCollection) {[NSTimerscheduledTimerWithTimeInterval:2target:selfselector:@selector(animateTimer:)userInfo:vc repeats:NO];}-(void)animateTimer:(NSTimer *)timer{ [selfperformSelectorOnMainThread:@selector(setShowGoldView:
Time of Update: 2018-12-05
NSLog(@"平方:%.f", pow(3,2) ); //result 9NSLog(@"上舍入:%.f", ceil(3.000000000001)); //result 4NSLog(@"四捨五入:%.f",round(3.30));//result 3NSLog(@"下舍入:%0.f",floor(232.90));//result 232NSLog(@"取最小的值:%0.02f",fmin(3.22, 22.22));//result
Time of Update: 2018-12-05
在objc中,開始是發送多個參數。這樣很麻煩。那麼可以用到c裡面的方式來做,通過struct傳遞參數。把相關的參數寫在一個struct裡面。聲明struct需要在標頭檔中:#define MIN_VELOCITY 10 #define LOOP_COUNT 100@interface AnimationView : UIView <UIGestureRecognizerDelegate>{ CALayer *startLayer; CALayer
Time of Update: 2018-12-05
h檔案#import <Foundation/Foundation.h>@interface HFTouchButton : UIButton{}@endm 檔案#import "HFTouchButton.h"@implementation HFTouchButtonbool touchMoved;- (id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) {
Time of Update: 2018-12-05
在Xcode 3.x中,將xib從iPhone版轉變為iPad版,通過Create iPad Version菜單。但在Xcode 4.x中,這個菜單找不到了。通過一番摸索,筆者發現可以用如下方法將xib轉換為iPad版本。1、修改xib源檔案xib檔案其實是一個xml檔案,你可以以文本方式編輯和修改它。在Project Navigator中,在xib檔案上右鍵,選擇“Open As ->Source
Time of Update: 2018-12-05
NSEnumerator有數種Cocoa類-包括各種群體類型在內-可以向您提供列舉程式,通過列舉程式,我們可以逐個取得執行個體持有的元素。例如:NSSet *aSet = // get a set;NSEnumerator *enumerator = [aSet objectEnumerator];id element; while ((element = [enumerator nextObject])) { /* code that acts on the element
Time of Update: 2018-12-05
在調用 removeFromSuperview 的時候,當前視圖會突然消失,這樣顯得很不友好。這段代碼能夠讓視圖慢慢消失。?123456789101112131415161718192021222324252627282930313233343536373839404142434445464748//// UIView+JTRemoveAnimated.h//// Created by james on 9/1/11.// http://ioscodesnippet.tumblr.com//
Time of Update: 2018-12-05
1,initWithCapacity:M 並不代表裡面的object數量不能大於M.也可以大於M. 2,init是在告訴程式,“我不知道要放多少object,暫且幫我初始化”。 3,如果你知道大概要放多少東西,那麼最好用initWithCapacity,這個會提高程式記憶體運用效率。4,如果你初始化了NSMutableDictionary,並且很長時間不會用到,建議用initWithCapacity:0。其它的如NSMutableArray,也是這個道理。
Time of Update: 2018-12-05
void ShowInfo( id formatstring,...){ va_list arglist;if (!formatstring) return;va_start(arglist, formatstring);id outstring = [[[NSStringalloc]initWithFormat:formatstringarguments:arglist]autorelease];va_end(arglist); [ [HFInfoView
Time of Update: 2018-12-05
//置中pick 字型- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel *label = [[UILabelalloc] initWithFrame:CGRectMake(0,0, 300,37)];// label.text =
Time of Update: 2018-12-05
1. 可以在背景播放聲頻的app。例如Instacast在播放一個部落格時。2. 可以在後台跟蹤你的位置的app。例如,TomTom導航系統,哪怕在另外一個app處於活動時,它也能發出語音提示。3. 監聽VOIP呼入的app。使用Skype時,當Skype在後台運行時,你仍然可以收到Skype來電。4. 可以下載新內容的報刊類app。5.