Orientation Configuration adapting to orientation changes.

Slides:



Advertisements
Similar presentations
Tutorial 3 – Creating a Multiple-Page Report
Advertisements

Paragraph Formatting Lesson 4.
Chapter 3 – Web Design Tables & Page Layout
Chapter 9 Working with Tabs and Tables. Chapter Objectives Work with tabs Create and format a table Format text in a table Place graphics in a table.
James A. Rome TGA August 2009 Mapping the TZs. In Java it is quite easy to do maps The only way to tell if we interpolated the data successfully is to.
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Microsoft Excel. Click on “Start,” then “Microsoft Office Excel.”
Page and Section Breaks, Word 2000
Chapter 3 Setting Up A Document.
COMPREHENSIVE Windows Tutorial 3 Personalizing Your Windows Environment.
1 Introduction to Word Chapter 3 Lecture Outline.
1 Microsoft Office Word 2003 Tutorial 3 Creating a Multiple-Page Report.
Advanced Microsoft Word Hosted by Jared Hoffman Topics Keyboard Shortcuts Customizing Toolbars and Menus Auto Format & Auto Correct Tabs Inserting Pictures.
Microsoft Word Review.
1 Excel Lesson 3 Organizing the Worksheet Microsoft Office 2010 Introductory Pasewark & Pasewark.
Xcode Presentation Tom Pletzke. Creating App from template Launch Xcode Select Tabbed Application.
Lesson 1 EQ: What are three ways to visually organize text?
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
iOS components in Swift
CIS 205—Web Design & Development Dreamweaver Chapter 5 Using HTML Tables to Lay Out a Page.
Adobe Dreamweaver CS3 Revealed CHAPTER FIVE: USING HTML TABLES TO LAY OUT A PAGE.
Paragraph Formatting Lesson 4.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
Sketchup Tutorial Designing for Construction. The Parts of a Wall.
This tutorial teaches Microsoft Word basics. Although knowledge of how to navigate in a Windows environment is helpful, this tutorial was created for.
XP New Perspectives on Microsoft Word 2002 Tutorial 31 Microsoft Word 2002 Tutorial 3 – Creating a Multiple-Page Report.
© 2010 Delmar, Cengage Learning Chapter 3 Setting Up A Document.
Week 11 Creating Framed Layouts Objectives Understand the benefits and drawbacks of frames Understand and use frame syntax Customize frame characteristics.
Tabbed Views UITabBarController. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and.
IOS with Swift Hello world app.
Working with Objects. Objectives Create an object Transform an object Arrange and lock an object Step and repeat an object Use Live Distribute Use the.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Gestures UIGestureRecognizer.
Chapter 4 Working with Frames. Align and distribute objects on a page Stack and layer objects Work with graphics frames Work with text frames Chapter.
© 2011 Delmar, Cengage Learning Chapter 3 Setting Up A Document.
© 2010 Delmar, Cengage Learning Chapter 4 Working with Frames.
Table Views UITableView.
© 2011 Delmar, Cengage Learning Chapter 4 Working with Frames.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
Microsoft Word 2000, Margins ITSW 1401, Intro to Word Processing Instructor: Glenda H. Easter.
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
Pasewark & Pasewark 1 Excel Lesson 3 Organizing the Worksheet Microsoft Office 2007: Introductory.
Change margins. 1 Preview a document. 2 Change paper size and orientation. 3 Print envelopes and labels. 4 Choose print options. 5 2.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
MS WORD INFORMATION TECHNOLOGY MANAGEMENT SERVICE Training & Research Division.
Day 1: MS Excel for Beginners Aniko Balogh CEU Computer & Statistics Center
Change margins. 1 Preview a document. 2 Change paper size and orientation. 3 Print envelopes and labels. 4 Choose print options. 5 2.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 5 1 Microsoft Office FrontPage 2003 Tutorial 5 – Creating Tables and Frames.
Windows Tutorial 3 Personalizing Your Windows Environment
Positioning Objects with CSS and Tables
Microsoft Word 2016 Lesson 4 Prepared 2/13/11.
Working with Tabs and Tables
Chapter 6 Working with Publisher Tables
Program and Graphical User Interface Design
Chapter 1 Editing a Photo
Windows xp PART 1 DR.WAFAA SHRIEF.
Tutorial 3 – Creating a Multiple-Page Report
Paragraph Formatting Lesson 4.
European Computer Driving Licence
Tutorial 6 Creating Dynamic Pages
Benchmark Series Microsoft Word 2016 Level 1
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
CSC 581: Mobile App Development
EEC-492/693/793 iPhone Application Development
Lesson 13 Editing and Formatting documents
University of Warith AL-Anbiya’a
Positioning Objects with CSS and Tables
Presentation transcript:

Orientation Configuration adapting to orientation changes

Orientation There are 7 possible orientations recognized by iOS: UIDeviceOrientationUnknown, UIDeviceOrientationPortrait, UIDeviceOrientationPortraitUpsideDown, UIDeviceOrientationLandscapeLeft, UIDeviceOrientationLandscapeRight, UIDeviceOrientationFaceUp, UIDeviceOrientationFaceDown

Using Orientations You can restrict which orientations your app will recognize Restrictions can be for the entire app or they can be for particular views Apple has different “recommendations” for different devices for iPad it is recommended that you always allow all orientations for iPhone/iPad touch allow landscape modes only if it works for your app for iWatch/wearables: we’ll see

Specifying Orientations at the app level

Specifying Orientations really, we’re changing the plist see Supporting Files->appName-Info.plist

Specifying Orientations per viewController specification: put this method in the viewController.m file. Must specify allowed orientations -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight; }

Specifying Orientations Orientation choices: UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationMaskPortrait UIInterfaceOrientationMaskPortraitUpsideDown Or combination choices: UIInterfaceOrientationMaskAllButUpsideDown UIInterfaceOrientationMaskAll UIInterfaceOrientationMaskLandscape

Specifying Orientations Interface Orientation vs Device Orientation Device depends on how the user is holding Cannot choose to accept it (the user changes it by how she holds the device) Interface you can choose to observer or not

Constraints can specify constraints if turn on autolayout Select the storyboard in the Project Navigator Click on the File Inspector then click on the Use Auto Layout checkbox It should be on by default This enables you to “pin” components via the Editor->Pin menu Auto Layout tutorial: XCode 5 Auto Layout tricksXCode 5 Auto Layout tricks

Constraints Create an interface that looks like this. Use blue dashed guidelines to line the buttons up.

Constraints Run. Change to landscape. Get this.

Constraints Fix 1: use Editor->Pin to pin elements to top/side/bottom. Or ctrl drag from component to the side you want to be constrained to. Do this for every element. See this in the document outline:

Constraints Fix 1: use Editor->Pin to pin elements to top/side/bottom. Or ctrl drag from component to the side you want to be constrained to. Do this for every element.

Constraints Now add a button as at right. add left and top constraints run This constraint is the problem!

Constraints Delete the constraint to top. ctrl-drag to left side choose Center Vertically in Container Fixed!

Aligning At the bottom of the view is a bar of layout controls. Similar to the Edit menu item Align Pin Resolve Auto Layout Issues Resizing Behavior Apply Retina 3.5-inch Form Factor

Aligning Add 3 text boxes and place as below make sure the boxes are offest and they are different widths

Aligning select all three textfields click on the Align button check “Bottom Edges” click on “Add 2 Constraints” button

Aligning select all three textfields click on the Pin button check “Equal Widths” click on “Add 2 Constraints” button

Aligning select leftmost textfield make sure it is the recommended distance from left border (blue dotted line) ctrl-drag to left border and choose “Leading Space to Container” ctrl-drag to top border and choose “Leading Space to Top Layout Guide”

Aligning select all rightmost textfield make sure it is the recommended distance from right border (blue dotted line) ctrl-drag to right border and choose “Trailing Space to Container”

Aligning Choose the “Resolve Auto Layout Issues” button. Click on “Update All Frames in View Controller” Result is not quite correct!

Aligning Move 2 nd text box to center (use the dotted center alignment line) Ctrl-drag from Text 1 box to Text 2 box and choose “Horizontal Spacing” Ctrl-drag from Text 2 box to Text 3 box and choose “Horizontal Spacing” Update all Frames in View Controller again

Aligning Run. Change orientations.

Other Methods In code. (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration { if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { button1.frame = CGRectMake(20, 20, 125, 125); button2.frame = CGRectMake(175, 20, 125, 125); button3.frame = CGRectMake(20, 168, 125, 125); button4.frame = CGRectMake(175, 168, 125, 125); button5.frame = CGRectMake(20, 315, 125, 125); button6.frame = CGRectMake(175, 315, 125, 125); } else { button1.frame = CGRectMake(20, 20, 125, 125); button2.frame = CGRectMake(20, 155, 125, 125); button3.frame = CGRectMake(177, 20, 125, 125); button4.frame = CGRectMake(177, 155, 125, 125); button5.frame = CGRectMake(328, 20, 125, 125); button6.frame = CGRectMake(328, 155, 125, 125); } we change the button position and size based on the orientation button1, button2, etc are IBOutlets to the buttons

Other Methods Swap views - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration { if (interfaceOrientation == UIInterfaceOrientationPortrait) { self.view = self.portrait; self.view.transform = CGAffineTransformIdentity; self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0)); self.view.bounds = CGRectMake(0.0, 0.0, 320.0, 460.0); } else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { self.view = self.landscape; self.view.transform = CGAffineTransformIdentity; self.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); self.view.bounds = CGRectMake(0.0, 0.0, 480.0, 300.0); } // rest of the method is in book… we change the view and size based on the orientation