我有一個UIAlertView與多個按鈕。是否有可能變灰並禁用按鈕?我希望按鈕可見,但清楚它不能被推。任何建議表示讚賞。UIAlertView灰色按鈕
0
A
回答
1
確保您已經啓用了當前VC作爲實施<UIAlertViewDelegate>
協議,然後在你的VC,你可以做到以下幾點:
- (void)viewDidAppear:(BOOL)animated {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert!" message:@"This is an alert view" delegate:nil cancelButtonTitle:@"Cancel!" otherButtonTitles:@"Off", @"On", nil];
alert.delegate = self;
[alert show];
}
/* UIAlertViewDelegate methods */
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView {
return NO;
}
// Other UIAlertViewDelegate methods...
現在,你爲什麼會想顯示一個按鈕一個UIAlertView中哪些沒有任何功能是一個完全不同的問題... :)
0
我聽到很多人繼承UIAlertView中的,但後來我讀了Apple's UIAlertView Class Reference page此評論:
子類注
的UIAlertView中類擬用作原樣,並且不 支持子類。該類的視圖層次結構是私有的,並且不得修改 。
即人們不應該試圖修改UIAlertView的元素或行爲。很可能在更高版本的iOS(例如iOS 8或iOS 7.1或其他)中行爲會發生變化,從而打破了對UIAlertView的各種修改。
不管怎麼說,爲了回答你的問題:爲什麼不嘗試創建你自己的UIView,你可以在你的任何視圖之上添加UIAlertView-like子視圖?這樣,您就可以輕鬆控制按鈕及其行爲。
相關問題
- 1. 灰色Toobar按鈕
- 2. 硒灰色按鈕
- 3. '灰色'WPF按鈕圖像?
- 4. TCL灰色檢查按鈕
- 5. 灰色狀態欄UIAlertView風格
- 6. 下一個按鈕是灰色的
- 7. Xcode:灰色已觸摸按鈕
- 8. 刪除按鈕周圍的灰色框
- 9. 配置下載按鈕灰色
- 10. Android WebView灰色播放按鈕
- 11. UIAlertView按鈕標記
- 12. UIAlertView按鈕操作?
- 13. 禁用UIAlertView按鈕
- 14. 如何將android按鈕更改爲深灰色而不是淺灰色
- 15. MFA按鈕灰顯
- 16. TextField覆蓋UIAlertView的按鈕
- 17. UIAlertView按鈕來顯示viewController
- 18. 更改UIAlertView按鈕佈局
- 19. UIAlertView無取消按鈕?
- 20. UIAlertView其他按鈕標題
- 21. IAP iOS UIAlertView取消按鈕
- 22. 移動按鈕UIAlertView中
- 23. UIAlertView按鈕動作代碼
- 24. UIAlertView按鈕事件問題
- 25. 帶19個按鈕的UIAlertView
- 26. UIAlertView沒有任何按鈕
- 27. 禁用按鈕爲灰色色彩目標C
- 28. Jquerymobile themeroller doesnt顏色提交按鈕,其保持灰色
- 29. 導航按鈕在轉換後將顏色更改爲灰色
- 30. 按下UIActionSheet按鈕後顯示UIAlertView