61、警告“addexplicit braces to avoid dangling else”
所謂“危急的else”是相似這種代碼:
if(a== 10)
printf("TEN");
else
printf("NOT TEN");
a = 100;
編譯器覺得你的else 子句導致語義不清,你究竟是什么意思?是不管 a 是否等於10 。 if 運行完之后都要將 a 賦值為100,還是僅僅想在 else 子句(即 a 不等於10 的時候)中將 a 賦值為 100?
假設是前者,正確的寫法應該是:
if(a== 10) {
printf("TEN");
}else{
printf("NOT TEN");
}
a= 100;
假設是后者。正確的寫法應該是:
if(a== 10) {
printf("TEN");
}else{
printf("NOT TEN");
a = 100;
}
當然。對於c/c++/java 編譯器來說。這僅僅是一個小問題,並不會導致無法編譯。編譯器實際上是傾向於前者的。它自己主動按第一種情況處理。
但它會警告你這是一種不好的代碼風格。你能夠用#pragma clang diagnostic ignored "-Wswitch" 宏忽略該警告。或者將編譯選項 MissingBraces and Parentheses 設置為 NO。
62、iPad模擬器不顯示 Home 鍵
從Xcode 4.3 開始,為了獲得更大的用戶可用空間,iPad 模擬器不顯示 Home 鍵。 你能夠通過菜單“ 硬件 > 首頁”或者快捷鍵⇧⌘H 來取代 Home 鍵。
63、Novisible @interface for 'NSURL' declares the selector 'query'
iOS6 中。該方法被拋棄,請用 NSURL+Parameters 替代。
64、certificateidentity 'iphone distribution' appears more than once
這是證書反復的錯誤。須要將鑰匙串里反復的證書刪掉編譯才干通過。
可是,假設你重新啟動Xcode ,會發現之前刪除的證書又回來了。但當又一次啟動Xcode時,Xcode里的證書會被導進鑰匙串。所以僅僅是刪除鑰匙串中反復證書是無效的。
相信 很多同學對 Xcode 的這個 Bug 深惡痛絕了,但除了反復地(可是徒勞地)從鑰匙串中刪除證書,也沒有別的辦法了。
事實上。也不能光怪 Xcode,而是跟”iPhone 配置使用工具“也有一定的關系。
Xcode中的這些“殘留”證書不以常規的形式存在。
假設你安裝了“iPhone 配置有用工具”,這些證書實際上存在於/Users/km-cn/Library/MobileDevice/Applications/文件夾下的.app 文件里,這些.app 實際上是 “iPhone配置有用工具”——“應用程序”中的所導入的 app。你能夠用Finder ——“顯示包內容”來查看.app 。
當中一個名叫“embedded.mobileprovision”的文件。就是“殘留”的反復證書。你能夠逐一刪除這些 .app,也能夠干脆把該文件夾下的全部.app 都刪除(反正僅僅要項目文件存在,你隨時能夠編譯出這些 .app並導入到“iPhone 配置有用工具”中)。最后,還要將 Orgnizer 中的反復證書也刪除,然后重新啟動Xcode。
65、Application Identifier 'com. ydtf.*' which doesn't match the current setting'com.ydtf.dlt'
如你所見,這兩個Application ID 絕對是匹配的(*表示通配符)。但這個莫名的錯誤會導致你始終不能編譯。這絕對是 Xcode 的還有一個 Bug,先將 CodeSigning 改動為 Don't Code Sign,Build。然后再改動回正確的簽名 Build。
66、Theidentity used to sign the executable is no longer valid.
因為前面的簽名問題導致不能Archive。解決方案見問題 65。
67、在iPad 中使用 presentModalViewController 設置彈出窗體的大小
TestViewController*testVC = [[TestViewController alloc] initWithNibName:@"TestViewController"bundle:nil];
testVC.modalPresentationStyle= UIModalPresentationFormSheet;
testVC.modalTransitionStyle= UIModalTransitionStyleCrossDissolve;
[selfpresentModalViewController:testVC animated:YES];
testVC.view.superview.frame= CGRectMake(0, 0, 649, 397);//it's important to do this afterpresentModalViewController
testVC.view.superview.center = self.view.center;
注意://it'simportant to do this after presentModalViewController。
即一定要在[selfpresentModalViewController:testVC animated:YES];之后設置frame的大小!
68、在iPad 中定制 ActionSheet 的button和Popover 箭頭方向。
ActionSheet在 iPad 上以Popover的方式顯示。默認不會顯示cancelButton(SDK用Popover之外的區域取代cancelButton,用戶僅僅要點擊Popover之外的區域就等同點擊取消button)。假設你這樣init一個ActionSheet:
UIActionSheet* sheet=[[UIActionSheet alloc]initWithTitle:nil
delegate:self
cancelButtonTitle:@"cancel"
destructiveButtonTitle:@"ok"
otherButtonTitles:nil];
則終於僅僅有紅色的destructiveButton 會顯示。
假設你非要顯示cancelButton,則能夠這樣干:
UIActionSheet* sheet=[[UIActionSheet alloc]initWithTitle:nil
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:@"cancel",@"ok",nil];
// sheet.cancelButtonIndex=0;
sheet.destructiveButtonIndex=1;
指定destructiveButtonIndex之后,該button被顯示為紅色。
但千萬不要指定cancelButtonIndex,因為在iPad上cancelButton會被移除。
在iPad中,SDK沒有提供能夠改動 actionSheet 的箭頭方向的API,系統自己主動推斷箭頭顯示的方向。
但我們能夠利用showFromRect的第1個參數來改變箭頭的方向:
CGRect r=sender.bounds;
r.size.width=2*self.view.bounds.size.width;
r.origin.x=-self.view.bounds.size.width+sender.bounds.size.width/2+sender.frame.origin.x;
[sheet showFromRect:r inView:sender animated:YES];
這樣就將原來的左箭頭,換成了上箭頭。
事實上iOS 在推斷 actionSheet 彈出方向時的邏輯非常easy,哪邊有“足夠”的空間,它就往哪邊彈出。當我們利用showFromRect的第1個參數將3個方向都“堵死”后。它就僅僅能老老實實地從我們想要的方向彈出了。
69、在 ASINetworkQueue 中 setShowAccurateProgress=YES 不起作用
在 networkQueue.showAccurateProgress= YES之前增加 request.showAccurateProgress= YES ,否則showAccurateProgress 不會生效。演示樣例代碼:
equest.showAccurateProgress=YES;
networkQueue.showAccurateProgress=YES;
[networkQueue setSuspended:YES];
[networkQueue addOperation:request];
networkQueue.uploadProgressDelegate=self;
[networkQueue go];
此外,因為 CFNework 中的一個 Bug,對於小於128K的數據,無法跟蹤其上傳/下載的精確進度。
70、怎樣設置 UIWebView 背景色為透明?
在IB中設置 UIWebView 的 Background 屬性為 Clear Color 並不能使其背景透明。要達到這個目的,你須要使用下面兩句:
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。