這是我在開發過程當中遇到的一些問題的整理,會按期作更新,但願對你們有所幫助^_^web
現象:app
若是在新建的UIWindow下添加UITextField或者UITextView後,長按此控件彈出來的放大鏡不是顯示當前文本的放大模式,而是顯示了底層的Window的內容。ui
環境:lua
iOS7+ 真機/模擬器spa
分析:線程
因爲Window的層次致使,默認的windowLevel是1。若是層次相同則會致使顯示不正常。調試
解決:code
建立新的UIWindow時將windowLevel調高一個層次則可解決問題。如:orm
_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];對象
_window.windowLevel = UIWindowLevelNormal + 1;
現象:
真機調試使用GameCenter進行用戶受權會報告錯誤: Error Domain=GKErrorDomain Code=15 "沒法完成所請求的操做,由於 Game Center 未識別此應用程序。"
環境:
iOS8 真機
分析:
有多是幾種狀況致使:
解決:
現象:
使用UIWebView的 stringByEvaluatingJavaScriptFromString方法時,在被執行的JS方法中不能有alert出現,不然可能會致使主線程阻塞。如:
OC中:
[webView stringByEvaluatingJavaScriptFromString:@「demo();"];
JS中:
demo () { alert(「test」); }
解決方法:
若是確實須要alert,則使用setTimeout方法執行。JS修改以下:
demo () { setTimeout (function () { alert(「test」); }, 100); }
現象:
當實體A與實體B之間是一對多關係時,爲實體A添加一個Relationship關聯實體B。當從實體A移除實體B的關係時,即便保存成功也沒法正真移除與實體B的關聯關係。
解決方法:
爲實體B提供一個逆向Relationship關聯到實體A後,移除關係功能正常。
現象:
彈出一個新建的UIWindow做爲keyWindow顯示界面後,在釋放該Window後,再次獲取keyWindow返回nil。代碼以下:
//顯示Window - (void)showWindow { self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.rootViewController = [[UIViewController alloc] init]; [self.window makeKeyAndVisible]; } //關閉Window - (void)closeWindow { self.window = nil; }
環境:
iOS 9
解決:
UIWindow及其子類若是爲keyWindow,則必須在dealloc以前調用resignKeyWindow,不然會致使key window丟失。則上面代碼能夠改成:
- (void)showWindow { self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.rootViewController = [[UIViewController alloc] init]; [self.window makeKeyAndVisible]; } - (void)closeWindow { [self.window resignKeyWindow]; self.window = nil; }
現象:
使用XCode運行調試App時,彈出提示框提示「the application could not be verified」。沒法運行應用。
解決:
因爲項目的Bundle Identifier包含非法字符串致使(可能包含中文)。修改此項爲英文字符便可。
現象:
真機調試出現:「process launch failed: failed to get the task for process 3835」
緣由:
打包證書使用了發佈證書致使。
解決方法:
在project的build settings -> Code Signing -> Code Signing Identity中修改調試用的開發者證書便可.