Download presentation
Presentation is loading. Please wait.
1
Apple Xcode with Swift Demo
Week 04 Apple Xcode with Swift Demo
2
iOS app to display an image
Click Launchpad from Mac to launch Apple Xcode. Click Xcode version 8.1 (for iOS 11.x) Click “Create a new Xcode project”. Choose: iOS – Application – Single View Application; then click “Next” button. Enter the following information: Product Name: ShowImage Organization Identifier: com.yourname Bundle Identifier: com.yourname.ShowImage Language: Swift Devices: iPhone Click “Next” Save project to “Desktop” – Click “Create”.
3
iOS app to display an image
Left upper corner should show the project name “ShowImage”. We only care about two modules: ViewController.swift and Main.Storyboard. Click “Main.Storyboard” from the left hand side; Click “View Controller” in the middle screen to see the design screen. On the top right hand side, click the “Show the Assistant editor” to put the design screen and the program screen side by side. (Adjust the screens if possible). Control Key + Click the “ShowImage” project icon on the upper left hand side, then click the “Add Files to ShowImage”. Click “all my files” to see all my image files. Select “swift.png” file; click “option”; check “copy if needed”; then click “Add”. Make sure swift.png file copy inside the project.
4
iOS app to display an image
Click “Main.Storyboard”, click “view” to adjust the design screen. On bottom right hand corner, click “show the media library” (icon likes a film). Drag and drop swift.png to design screen. Adjust size if possible. Highlighted the swift.png in the design screen, check the “Hidden” button from “Drawing” property on the right hand screen. Next to the “media library”, click the “show the object library” (icon likes an eye). Search for button object, drag and drop button object to design screen. Adjust it if possible. Highlighted the button, enter “Display Image” into Title property on the right hand screen.
5
Start codeing Control key + Click the swift.png, click the “New Referencing Output”, drag and drop to ViewController.swift which is next to the design screen on the right. This object should put it after the “Class” and before the “Override Func”. Name: swiftImage Click “Connect” to complete. Control key + Click the “Display Image” button, click and drop the “New Referencing Output” to ViewController.swift after the above object. Name: displayButton
6
Start coding Continue from the above step, from “Sent Event”, Click + drop the event “Touch up Inside” to “ViewController.swift” after the above objects. Name: actionDisplayImage Click “Connect” to complete Inside the “actionDisplayImage function” in the “ViewController.swift”, add the following single statement: swiftImage.isHidden = false;
7
Testing and Debugging Click “Play” to build and test the program.
Click the simulator to see the output, click the “Display Image” button to see the swift image. Click the “stop” simulator button. Quit Simulator Quit Xcode Note: next time, click the “ShowImage” icon, click “ShowImage.Xcodeproj” to open the Xcode again.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.