iOS Dev 46 uses the UIButton and Uiimageview differences to distinguish which controls have Addtarget listener events this method

Source: Internet
Author: User

(1) Similarities of UIButton and Uiimageview

can display pictures.


(2) different points of UIButton and Uiimageview

-The former can not only display pictures but also listen to events (there is Addtarget method)

The former can not only show the picture but also show two pictures (SetImage and setbackgroundimage two methods)

The former can not only display the picture but also display the text (that is, the Settitle method)


(3) Use occasions

--If you just show a picture no other flower head, then use Uiimageview

-If there are other, then ...

Because if only for the display of pictures, UIButton control compared to the Uiimageview control will be more memory, after all, UIButton function, like a package, although it is an empty package, but the package itself is very large, then it will certainly be relatively heavy.


(4) deep-seated reasons.

--uibutton inherited from Uicontrol,uicontrol inherited from UIView

--uiimageview directly inherit from UIView


(5) Summary

--the control that inherits from Uicontrol has the Addtarget method, because this method is Uicontrol, inherits from it, of course this method also inherits, actually UIButton call this method to call its parent class namely Uicontrol.

--If you want to see if a control supports event monitoring, then long cmd+ Click to see if it inherits from Uicontrol, such as UISlider.

iOS Dev 46 uses the UIButton and Uiimageview differences to distinguish which controls have Addtarget listener events this method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.