我想動態地將UIbutton
作爲子視圖添加到UIlable
。但我無法點擊按鈕。看來標籤不允許buttonTapped事件發生。
有人可以解釋究竟發生了什麼嗎?任何人都可以爲我提供替代方案嗎?謝謝!UIButton作爲子視圖在UILabel
回答
有趣的是,在發佈這個問題5分鐘後,我自己得到了答案。看來,我必須在標籤上啓用我的userInteraction。
即 -
lbl.userInteractionEnabled=YES;
可能不是最好的方法來設置,但它的工作原理。 – Intentss 2010-06-11 22:47:20
你的問題(以及隨後的回答)不給做你嘗試什麼樣的智慧(或缺乏)說。 UILabel
對象通常不是互動的,並且將UIButton
作爲子視圖放置到標籤上,僅僅因爲您可以做到這一點,聽起來根本聽起來不像是遵循Apple HIG for iPhone。
這個問題的答案如何? – Esqarrouth 2015-04-04 17:40:30
@Esq這是一個答案!我有同樣的問題。現在,不是使用UILabel,而是將其更改爲UIView,這可能是更好的方法。 – LevinsonTechnologies 2015-09-07 21:05:16
- 1. UIButton和UILabel不從UIButton更新視圖
- 2. UIButton作爲子視圖編程約束
- 3. UIButton在當前視圖添加子視圖後無法工作
- 4. UIButton作爲UITableViewCell子視圖的一部分 - 使其工作
- 5. 刪除UIButton的子視圖
- 6. 曖昧約束添加的UILabel當作爲子視圖的UITextView
- 7. UILabel在不同子視圖中
- 8. 將UIButton作爲子視圖添加到UITabBar
- 9. iOS UILabel子視圖有時顯示比其他子視圖晚
- 10. 爲textLabel作爲子視圖
- 11. UIButton在子視圖中觸發當前ViewController中的動作
- 12. 從UIButton獲取UILabel
- 13. UITableViewCell與UILabel子視圖緩存問題
- 14. 如何更新inputView子視圖的UILabel?
- 15. 如何刪除子視圖是UILabel
- 16. 作爲子視圖的頁面視圖
- 17. 子視圖用的UIButton無法點擊
- 18. 從子視圖中的UIButton加載tabBarController
- 19. 攻絲UIButton,這是UIView的子視圖
- 20. UIButton的子視圖需要釋放?
- 21. 聲明的UIButton的子視圖
- 22. 添加自定義UIButton到子視圖
- 23. iPhone UIView動畫禁用UIButton子視圖
- 24. 作爲子視圖的UIPickerView
- 25. tabbarcontroller作爲子視圖
- 26. NavigationController作爲子視圖
- 27. SFSafariViewController作爲子視圖
- 28. iPad SplitView作爲子視圖
- 29. 奇怪的UILabel和UIButton的行爲
- 30. 添加的UIButton到子視圖不工作
也許將UILabel和UIButton都添加到包裝UIVIew中會更好? – texmex5 2010-05-08 08:31:29