Controller, easy! We take out the code in UIView

 3r???. 3r3-31. Do you have a big UIViewController? For many, yes. On the one hand, it works with data, on the other - with the interface. 3r3499.  3r???. 3r3499.  3r???. The tasks of separating logic from an interface are described in hundreds of articles about architecture: MVP, MVVM, VIPER. They solve the problem of data flow, but do not answer the question of how to work with the interface: in one place remains the creation of elements, layout, configuration, input processing and animation. 3r3499.  3r???. 3r3499.  3r???. Let's separate the view from the controller and see what loadView () will help us with. 3r3499.  3r???. 3r3499.  3r???. 3r314. 3r3499.  3r???. In the example on GitHub You can look at the division of classes for a simple task: the color of the square depends on its position (in the green area it is green, outside it is red). 3r3499.  3r???. 3r3499.  3r???. The more complex the screen, the better the effect: the controller decreases, the code is transferred to its places. The code is simply transferred to r3r3501. view but encapsulation simplifies communication and code reading. Sometimes view can be reused with another controller. For example, different controllers for the iPhone and iPad react differently to the appearance of the keyboard, but this does not change the code view . 3r3499.  3r???. 3r3499.  3r???. I used this code in different projects and with different people, each time the team welcomed the simplification and picked up the practice. I hope you enjoy it too. All lung r3r3501. UIViewController ! 3r? 3510. 3r???. 3r???. 3r???.
3r???. 3r? 3510. 3r???. 3r???. 3r???. 3r???.
+ 0 -

Add comment