IOS development skills (1)
This series of articles simply summarize some of the skills in the development process for future reference. ExclusiveTouchexclusiveTouch is an attribute of UIView. Exclusive means "Exclusive", so the function of this method is to set the touch event of a UIView as an Exclusive event, that is, if multiple uiviews with exclusivetouch set are clicked at the same time, then, only one event is responded. This method can be used to solve the problem of multi-Event Response Caused by simultaneous clicking of multiple buttons. AttemptRotationToDeviceOrientation this is a static method of UIViewController, used to evoke screen rotation. When the direction of UIViewController is different from that of the screen, This method allows UIViewController to rotate the screen. This method is generally used to cope with the product requirements of the pitfalls. a vertical screen is displayed on a certain interface, while a horizontal screen is displayed on another interface. ViewWillLayoutSubviews is a method of UIViewController, which is similar to viewDidLoad and viewWillAppear. This method is called after UIView calls layoutSubviews. As a subclass of UIViewController, this method can be implemented to re-adjust the interface. This method is used because in Storyboard, we usually display controls of a certain size. When a view is actually loaded, that is, in viewDidLoad, the display size of our controls is the corresponding size in the Storyboard. Even if the actual screen size is different from that in the Storyboard, the size in the Storyboard is used. The problem is that the control fails to be initialized in a timely manner, especially the control that needs to determine the layout of the subview Based on The View Size, which has a great impact. So it is the correct method to re-adjust our controls in viewWillLayoutSubviews. If you want to arrange several views horizontally and with equal width and equal distance, you can set the spacing constraints between them and their width equal constraints. You can use either of the following methods to arrange several views with known widths in an equal distance. One is to place a new view in the center of each view based on the above method. Another method is to set the alignment Center for each view and modify the Multiplier to offset the view, check whether the multiplier is correct by selecting the control, holding down the option key, and moving the mouse over another control to view the distance between two views. The constraints on the view on the Constrain to marginsStoryboard are usually selected by default, which means that it has a certain offset value with the parent view. This option will lead to the deviation between our design and development. If you need to customize your own view height, you need to remove this constraint.