Structuring app views for iPhone / iPad

I have an idea about the application that I want to create, and about the new iPhone / iPad for development (but not new to developing in other languages ​​/ frameworks such as .NET and Java). I want some views to be displayed on some screens so that they can move (move) from different directions to different places.

A question about the structure of the application, if I say four rectangular areas on the screen that contain business data, such as contacts (name, photo, etc.), and they all occupy a different width (for example, the first contact occupies one line of the screen, and the next 2 occupy half the width of the next line, etc.).

Should I create a custom view for different types of contacts (for example, LargeCustomView and SmallCustomView and any other special type that I make), or will it all be one type, say CustomerDetailsView, which can be stretched to fit the design time?

In addition, if, for example, there were 3 different instances of the same user view on the same screen, are there 3 more instances of the view controller? I got a little confused about including data behind a look, can someone shed some light on this for me? Did I just set properties (e.g. ContactForView instance variable) on the view controller for each instance?

Thanks for any help you can give.

Greetings

Mark

+4
source share
1 answer

Should I create a custom view for different types of contacts (for example, LargeCustomView and SmallCustomView and any other special type that I make), or will it all be one type, say CustomerDetailsView, which can be stretched to fit the design time?

I think you can only answer this question. If the UIView autoresizing mask is enough to support both layouts, you should probably go only for one class. If this is not enough, you can either redefine layoutSubviews for an account of different sizes, or perhaps go with a common superclass to contain logic and two subclasses to execute different layouts.

In addition, if, for example, there were 3 different instances of the same user view on the same screen, are there 3 more instances of the view controller?

Because of how the UIViewControllers works, Apple usually recommends not having more than one on-screen view controller. From the docs:

You cannot use view controllers to manage views that fill only part of their window, that is, only part of the area defined by the rectangle of the application content. If you want to have an interface consisting of several smaller views, paste them all into one root view and manage that view using your view controller.

Otherwise, things like rotating the device can become complicated, because a view controller that is not full-screen should probably respond differently to such events, and Apple's UIViewController is not written for that. However, no one is stopping you from writing your own view controllers (derived from NSObject , not from the UIViewController ), so I would recommend: if the view is rather complicated, write your own controller class for it, but stick to one UIViewController on the screen.

+1
source

Source: https://habr.com/ru/post/1308588/


All Articles