Lecture 5

Lecture 5 - Stanford CS193p Fall 2011 Developing...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Stanford CS193p Fall 2011 Developing Applications for iOS Fall 2011 Stanford CS193p Stanford CS193p Fall 2011 Today A couple of more things about last Thursdays demo Why no weak or strong on the @property (readonly) id program ? [CalculatorBrain ... ] or [[self class] ... ] when calling a class method from an instance method? Autorotation And how your custom UIView will react to bounds changes And how to initialize a UIView (its more than just overriding initWithFrame: ) Objective C Protocols Gesture Recognizers Handling Touch Input Demo Happiness Custom UIView with Gestures Stanford CS193p Fall 2011 Autorotation What goes on in your Controller when the device is rotated? You can control whether the user interface rotates along with it Implement the following method in your Controller- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { return UIInterfaceOrientationIsPortrait(orientation); // only support portrait return YES; // support all orientations return (orientation != UIInterfaceOrientationPortraitUpsideDown); // anything but } If you support an orientation, what will happen when rotated? The frame of all subview s in your Controllers View will be adjusted. The adjustment is based on their struts and springs. You set struts and springs in Xcode. When a views bounds changes because its frame is altered, does drawRect: get called again? No. Stanford CS193p Fall 2011 Struts and Springs Set a views struts and springs in size inspector in Xcode Preview Click to toggle on and off. Stanford CS193p Fall 2011 Struts and Springs Set a views struts and springs in size inspector in Xcode Grows and shrinks as its superview s bounds grow and shrink because struts xed to all sides and both springs allow expansion. Stanford CS193p Fall 2011 Struts and Springs Set a views struts and springs in size inspector in Xcode Grows and shrinks only horizontally as its superview s bounds grow and shrink and sticks to the top in its superview . Stanford CS193p Fall 2011 Struts and Springs Set a views struts and springs in size inspector in Xcode Sticks to upper left corner (xed size). Stanford CS193p Fall 2011 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 ... Luckily, there is a UIView @property to control this! @property (nonatomic) UIViewContentMode contentMode; UIViewContentMode{Left,Right,Top,Right,BottomLeft,BottomRight,TopLeft,TopRight} The above is not springs and struts! This is after springs and struts have been applied! These content modes move the bits of your drawing to that location....
View Full Document

Page1 / 29

Lecture 5 - Stanford CS193p Fall 2011 Developing...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online