Uploaded October 2012 | Updated September 2026, 2 weeks ago
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
techytube.com/author/pavel
A "view" is any object of the UIView class or of one of its subclasses. That means any UI control, such as buttons, sliders, steppers etc. is a view.
Usually, when creating view that should be present on our .xib or .storyboard files, we do that visually, using Interface Builder, which is integrated in Xcode 4.
However, some situations may appear when we need do add different views dynamically on our screens, and for doing that, we need to do that programatically (Which basically has the same effects).
To create a view, we write the following code:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
We can also set the view's properties, for example the background colour:
view.backgroundColor = [UIColor redColor];
And finally we need to add that to our main view:
[self.view addSubview:view];
We can do the same thing for other classes that inherit from UIView, for example UIButton:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Click me" forState:UIControlStateNormal];
button.frame = CGRectMake(0, 300, 200, 60);
[self.view addSubview:button];
For more details, please visit Apple's Online Documentation at:
developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
techytube.com/author/pavel
A "view" is any object of the UIView class or of one of its subclasses. That means any UI control, such as buttons, sliders, steppers etc. is a view.
Usually, when creating view that should be present on our .xib or .storyboard files, we do that visually, using Interface Builder, which is integrated in Xcode 4.
However, some situations may appear when we need do add different views dynamically on our screens, and for doing that, we need to do that programatically (Which basically has the same effects).
To create a view, we write the following code:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
We can also set the view's properties, for example the background colour:
view.backgroundColor = [UIColor redColor];
And finally we need to add that to our main view:
[self.view addSubview:view];
We can do the same thing for other classes that inherit from UIView, for example UIButton:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Click me" forState:UIControlStateNormal];
button.frame = CGRectMake(0, 300, 200, 60);
[self.view addSubview:button];
For more details, please visit Apple's Online Documentation at:
developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html








![Instance Methods and Class Methods in Objective-C
Subscribe to our channel here for notifications on new video trainings. For more videos on technology, visit our website at http://www.techytube.com.
By pavel@techytube, for more from this author visit:
http://www.techytube.com/author/pavel
Instance Methods and Class Methods in Objective-C is very similar to the same concepts implemented in other object oriented programming languages.
Instance methods are the usual methods, and we always need some object(s) to call those specific methods. When we declare and implement them, we always start with the - (minus sign). The syntax for calling an instance method is:
[objectName instanceMethodName];
For class methods we do not need any object created in our program in order to call them.
They always start with the + (plus sign). The syntax for calling a class method is:
[ClassName classMethodName]; Instance Methods and Class Methods in Objective-C](https://i.ytimg.com/vi/sjFLaJD_cgA/mqdefault.jpg)

