2016-07-04 28 views
0

我一直試圖通過調用dismissViewControllerAnimated解僱我的警報視圖,但不幸的是我沒有得到我想要的,因爲它將我發送到rooviewController(「UsersSwippingViewControllerUsers」/「Users 「),而不是留在提交它的視圖控制器(chatViewController)..dismissViewControllerAnimated從UIAlertController調用發送給我RootViewController

請你幫我一下。 我附上了我用來調用dismissViewControllerAnimated的代碼和我的故事板的屏幕截圖,讓您大致瞭解我的應用程序的外觀。該應用程序帶我到的視圖控制器是「UsersSwippingViewControllerUsers」/「用戶」,當它應該留在/帶我去ChatViewController。

截圖:

This is a preview of my app's storyboard

Here is the code I'm using dismissViewControllerAnimated in the handler of the UIAlertAction

回答

-1

變化行動的類型.Cancel而不是.DEFAULT爲CancelAction,它應該工作。

self.dismissViewControllerAnimated只能在演示者視圖控制器中調用,而不是演示者調用。

希望它可以幫助

+0

>將操作類型更改爲.Cancel - 這不是必需的。你可以保持UIAlertActionStyle.Default。 –

0

不要在UIAlertController行動使用dismissViewControllerAnimated方法。這樣做,你告訴你的父視圖控制器實例被解僱(注意爲什麼你在關閉中使用self!)。並且UIAlertController有默認方法在任何按鈕按下後自動解除。

+0

刪除dismissViewControllerAnimated將導致UIAlertController永遠不會關閉/關閉。 – Mystic

+0

@Mystic嘗試在函數'textFieldDidBeginEditing'的開始處添加'view.endEditing(true)'行。 –

相關問題