Foundational Flashcards
(110 cards)
how do we grow app to handle multiple MVC?
we use storyboards and we use “controllers of controllers”, for example, a UINavigationController.
how does “controllers of controllers” structure the multiple MVCs?
it points to a root view controller, it embeds an MVCs View inside its View, then a UI element in this View can segue to another MVC and its View is now embedded in the “controller of controllers” View
how do you “conditionally” segue?
call perform segue with identifier
when a segue happens, what goes on in my code?
source VC offers a chance to “prepare” the destination VC, before it comes on
how do we think of the new MVC we segue to?
we think of it as part of the “View” of the source VC: it communicates through delegation only in this case since target/action is not applicable here.
What goes on in your Controller when the device is rotated?
You can control whether the user interface rotates along with it using (BOOL) should autorotate to interface orientation
If you support an orientation, what will happen when rotated?
The frame of all subviews in your Controller’s View will be adjusted. The adjustment is based on their “struts and springs” you set in the size inspector in XCode. When a view’s bounds changes because its frame is altered, does drawRect: get called again? not by default, but you can change it so that it does redraw
When a view’s bounds changes because its frame is altered, does drawRect: get called again?
not by default, but you can change it so that it does redraw
What will happen when for a subview with “struts fixed to all four sides and both inner springs allow expansion”?
It grows and shrinks as its superview
’s bounds grow and shrink
What will happen when for a subview with “struts fixed to top, left, right sides (not bottom) and only the horizontal inner springs allow expansion (not vertical)”?
Grows and shrinks only horizontally as its superview grow and shrink and sticks to the top in its superview.
Redraw on bounds change?
By default, when your UIView’s bounds change, no redraw Instead, the “bits” of your view will be stretched or squished or moved. Often this is not what you want …
How do you change the default, meaning, when your UIView’s bounds change, how to you set redraw?
Use the UIView @property (nonatomic) UIViewContentMode contentMode; Assign value UIView Content Mode Redraw.
When is initWithFrame called?
When you instantiate with alloc] initWithFrame…
How do you override initWithFrame: ?
self = [super initWithFrame: aRect]
Why use awakeFromNib method ?
Because initWithFrame is NOT called for a UIView coming out of a storyboard, but awakeFromNib is. So you want to put set up stuff in awake from Nib.
Typical initFromFrame: code ?
self = [super initWithFrame:aRect];
[self setUp];
return self;
What are protocols?
Protocols are similar to @interface, but someone else does the implementing.
Where are protocols defined?
In its own header file, or in the header file of the class that wants other classes to implement it.
What does this mean? @protocol Foo
Implementors must implement Foo being declared here, as well as Other.
What does this mean: @interface MyClass : NSObject
MyClass is a kind of NSObject that implements the Foo protocol
id obj = [[MyClass alloc] init];
Declaring an id variable with a protocol requirement
What is the #1 use of protocols in iOS?
delegates and data source
@property (nonatomic, weak) id delegate;
@property (nonatomic, weak) id dataSource;
data source is just like delegate except it’s for delegating data
Why do Views commonly have a dataSource delegating provisions of data?
Because Views cannot own their own data.
How is protocol like static typing?
They’re both compiler-helping-you stuff. They make no difference at run-time. They’re documentation for you method interfaces as well.