Conceptually, subclass UIView correctly?

(I’m not saying that this is not so, it asks me more to make sure that I am implementing the object-oriented principles correctly.)

Let's say I want to create UIViewwith UIImageViewin it and UILabelunder the heading UIImageView.

In an iOS application, the best way to reuse this installation UIViewif I wanted to have it in several parts of my application?

It seems that many of the tutorials I read point to a subclass UIView, and in one of the methods, initcreate routines and then add them to selfand voila, just create new instances of this UIViewand you have an implementation . reusable

But does it really make sense to be a subclass of UIView? I understand that subclasses and inheritance are a bit of a superclass called Vehicle, and you create a subclass of it Truck. If you look at this, the “Truck” is the “Vehicle” that I understood inheritance.

Whether there is a

The caption image is a view

Make conceptual meaning in inheritance? I know that many will say: "Of course!" but I just look at it and think that it’s not really a derivation or setting up a superclass, but a union of others.

If I create something like this, I almost think I want to use a reusable user instance of UIView, not a subclass of UIView, but maybe I am using a too harsh definition of the subclass.

, UIButtons , ? ?

? , , ?

+3
4

- . , UILabel UIImageView UIView. UIKit UIView. - . , , .

+4

+ nib/xib, . , .

+1

- , , UIView, UIView, , , .

, - . - , JavaScript, , . Objective-C . ( , , , , ... .)

. UIViewController, UIView. . , UIKit , UIView, . UIView. () ObjC. .

, UIView . . nib. nib - , , ( , ). Interface Builder, UINib. , UIView.

, (, - ). NSCoding ( , ). .

, , , UIView .

0

, . DDDImageCaptionView

Make sure you have a good model, view and controller to make sure you are not using the view to store data, the view should be dumb and show what is said.

0
source

All Articles