• Storyboarding is a feature built into XCode that allows both the various screens that comprise an iOS application and the navigation path through those screens to be visually assembled.
• Using the Interface Builder component of XCode, the developer simply drags and drops view and navigation controllers onto a canvas and designs the user interface of each view in the normal manner.
• The developer then drags lines to link individual trigger controls (such as a button) to the corresponding view controllers that are to be displayed when the control is selected by the user.
• Having designed both the screens (referred to in the context of storyboarding as scenes) and specified the transitions between scenes (referred to as segues) XCode generates all the code necessary to implement the defined behavior in the completed application.
• The style of transition for each segue (page fold, cross dissolve etc.) may also be defined within Interface Builder.
• Further, segues may also be triggered programmatically in situations where behavior cannot be defined graphically using Interface Builder.
Apple provides dozens of frameworks for iOS (and their other operating systems as well such as macOS, watchOS, and tvOS). By simply using Apple’s frameworks, you can accomplish common tasks by writing little code of your own. Some of Apple’s available frameworks include
• UIKit – iOS user interface and touch screen support
• ARKit – Augmented reality features
• Core Animation – Displays animation
• GameKit – Creates multiplayer interactive apps
• Contacts – Accesses the Contacts data on an iOS device
• SiriKit – Allows the use of voice commands through Siri
• AVKit – Allows playing of audio and video files
• MediaLibrary – Allows access to images, audio, and video stored on an iOS device
• CallKit – Provides voice calling features
1. Open File->New->Project…
2. Create Single View App, name: “Segue”, Interface: Storyboard. We will have a default ViewController UI and a ViewController.swift file.
3. Add another ViewController and another swift file name: “Scene2ViewController.swift” and layout the storyboards
4. Control drag from button in Scene1 into area in Scene2 to create a modal segue and control drag from button in Scene2 into Exit icon of Scene2 ViewController to create a return segue.
5. Connect swift file “Scene2ViewController.swift” to a second view controller, usually one view controller, one swift file.
6. Create outlets for both labels
7. Connect scene1Label to outlet in ViewController
8. Connect scene2Label to outlet Scene2ViewController
9. Create prepare for segue to passing data between scenes, when transition from scene1 into scene2, send text label to scene2 and vice versa.
18. กด control ค้างไว้ กดเมาส์บนเลเบลที่ใช้แสดงตัวเลข แล้วดึงไปวางบน view controller ด้านบนฟังก์ชัน numbers เพื่อสร้างตัวแปรในโปรแกรมที่เชื่อมกับกับเลเบล ตัวแปรแบบนี้เราเรียกว่า Outlet ตั้งชื่อว่า result แล้วกด Connect
19. สร้างตัวแปรที่เกี่ยวข้องสำหรับใช้ในการเก็บค่าของตัวเลขที่แสดงบน result เลเบล ต่อจาก result ดังนี้
var numberOnScreen: Double = 0;
var performingMath = false;
var previousNumber: Double = 0;
var operation = 0;