2014年7月19日 星期六

[iOS] Custom UIAlertView for iOS 7

自從 iOS 7 開始,很多人說無法加入 custom view。

若要帶輸入框(UITextField)的話,雖然本身有提供好幾種模式,如:UIAlertViewStyleLoginAndPasswordInput (帳號&密碼)、UIAlertViewStylePlainTextInput (文字)等。

結果發現要做個重設密碼,需要2個 UITextField 且為 Secure 模式就無法度了,因為 UIAlertViewStyleLoginAndPasswordInput 其中有1個不是 Secure 模式。

拜讀 google 大神後找到好心人提供方法,去設定 UIAlertView 裡的 accessoryView 參數即可。
[alertView setValue:customContentView forKey:@"accessoryView"];

參考來源:http://stackoverflow.com/questions/18886048/ios-multiple-text-fields-on-a-uialertview-in-ios-7

1 則留言:

  1. 請問在iOS8的話要如何做呢?在iOS8UIAlertView被拿掉改以UIAlertController了,若要customize view在UIAlertController顯示要如何作?謝謝。

    回覆刪除