iOS 常見問題解決辦法

1.在項目中碰到一個問題:在UIWebView中,調用原生相機或圖庫,程序會重啟到啟動畫面。查看打印信息,如下:

Warning: Attempt to present <UIImagePickerController: 0x12734be00> on <MBTabBarVC: 0x1270fc000> whose view is not in the window hierarchy!

網上查了很多資料才知道,選擇一個選項時,會把當前的ViewController dismiss掉,但是這里貌似是一個bug,dismiss了兩次,結果第二次把tabbar(我的項目是tabbar-nav-viewController)給銷毀了(斷點到dealloc可以看到),然后就理所當然的崩潰了。

解決辦法:
在自定義的tabbar中,重寫dismiss方法,之所以第二次會dismiss tabbar,是因為第二次dismiss時,self.presentedViewController是一個nil。所以解決代碼如下:

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
    if ( self.presentedViewController)
    {
        [super dismissViewControllerAnimated:flag completion:completion];
    }
}

參考:ios 10 在WebView中選擇文件上傳 出現 whose view is not in the window hierarchy!


2.Xcode 7以后沒有dylib文件

解決辦法:

  1. Go to Build Phases >Link Binary with Librairies > + > Add other
  1. Once in the file selection window do "CMD"+Shift+G (Go to folder) and type /usr/lib/
  2. From /usr/lib you can add : libz.dylib and more...
  3. Compile and have fun

參考:libz.dylib not found

3.Profile doesn't match the entitlements file's value for the application-identifier entitlement

解決辦法:
target-capbilities-打開iCloud,然后關閉icloud,即可

Profile doesn't match the entitlements file's value for the application-identifier entitlement

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容