我想動態地將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. 添加一個UILabel作爲UIButton的子視圖不會觸發按鈕動作
- 3. UIButton作爲UITextfield的子視圖
- 4. UIButton作爲複雜的UIScrollView子視圖
- 5. UIButton作爲子視圖編程約束
- 6. 在UITextView上添加一個UILabel作爲子視圖
- 7. UIButton在當前視圖添加子視圖後無法工作
- 8. UIButton作爲UITableViewCell子視圖的一部分 - 使其工作
- 9. 作爲MKAnnotationView中子視圖的UIButton不起作用
- 10. 刪除UIButton的子視圖
- 11. 添加子視圖的UIButton
- 12. 曖昧約束添加的UILabel當作爲子視圖的UITextView
- 13. 製作的UIButton中的子視圖訪問父視圖 - 控制
- 14. UILabel在子容器視圖不更新
- 15. UILabel在不同子視圖中
- 16. 作爲子視圖添加UIButton遠離UIView
- 17. 將UIButton作爲子視圖添加到UITabBar
- 18. 如何添加uibutton,uiimage作爲mpmovieplayercontroller的子視圖?
- 19. 是否可以將UILabel添加到已經將UIButton作爲子視圖的UITableView Cell中?
- 20. 如何子類UI元素,如UILabel,UIButton
- 21. iOS UILabel子視圖有時顯示比其他子視圖晚
- 22. 爲textLabel作爲子視圖
- 23. UIButton不能在動畫子視圖上工作
- 24. UIButton在子視圖中觸發當前ViewController中的動作
- 25. 爲什麼UILabel不會出現在子視圖中?
- 26. 從UIButton獲取UILabel
- 27. 在UIScrollView中添加爲子視圖的UIButton的觸摸檢測
- 28. 如何更新inputView子視圖的UILabel?
- 29. 如何刪除子視圖是UILabel
- 30. UITableViewCell與UILabel子視圖緩存問題
也許將UILabel和UIButton都添加到包裝UIVIew中會更好? – texmex5 2010-05-08 08:31:29