a view has only one superview - (UIView *) superview;
But can have many(or zero) subviews -(NSArray *) subviews;
subview order matters.
UIWindow
the UIView at the top of the view hierarchy.
Only have one UIWindow in an iOS application.
It is all about UIViews.
always use CGFloat for graphics.
CGPoint p = CGPointMake(34.5,22.0);p.x += 20; CGSize CGSizeMake CGRect CGRectMake
coordinate system is upper left -----> x
units are "points" not pixels!
@property CGFloat contentScaleFactor
view's 3 properties
@property CGRect bounds;//internal@property CGPoint center;//the center in your superview's coordinate system@property CGRect frame;// a rectangle in your superview's coordinate space which entirely contains your view's bounds.size
when view rotated, bounds and frame are different.
to customize view
drag out a generic UIView from the palette and use the Inspector to change the class of the UIView to your custom class.
autorotation
implement the following method in your controller
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) orientation{}
content mode
By default, when your UIView's bounds change, no redraw.
luckily, there is a UIView @property to control this.
@property (nonatomic) UIViewContentMode contentMode;
Default is UIViewContentModeScaleToFill.
protocol
@protocol Foo- (void) doSomething;@optional@required@property@end
UIGestureRecognizer
how can we react to certain "gestures"?
there are two steps to using a gesture recognizer
- adding a gesture recognizer to a UIView
- provide a gesture handler
UIViewController
mvcs working together
how do we switch the screen to show another mvc
controller of controller
UINavigationController
it's special because we can set its rootViewController outlet to another MVC...
A UI element in a view can segue to the other MVC and its view will now appear in the UINavigationController
to create a segue, you hold down ctrl and drag from the button to the other view controller.
Is Initial View Controller
Embedded in Navigation Controller
UIView obtained from the view property of the UIViewController most recently pushed (or root).
NSString obtained from the title property of the UIViewController most recently pushed (or root).
An NSArray of UIBarButtonItems obtained from the toolbarItems property of the UIViewController most recently pushed.
back button -- title property of the previous view
- (IBAction) rentEquipment{ if(self.snowTraversingTalent ==Skiing){ [self performSegueWithIdentifier:@"AskAboutSkis" sender:self]; }}
prepareForSegue
- (void) prepareForSegue: (UIStoryboardSegue *) segue{}