For my first iOS tutorial on TechRepublic, I will describe how to create the typical Hello World application for iPhone, which we will build on in future posts. I assume you have an Intel-based Mac with Xcode installed.
1. Launch Xcode and create a new project by clicking the Create A New Xcode Project button on the splash screen (Figure A). Or, if you dismissed the splash screen, you can select File | New | Project from the menu. Select Single View Application from the list of templates.Figure A
2. Verify that all of these options are set in the next dialog box (Figure B) – if you don’t, you will have problems following this tutorial:
- Product Name is Hello.
- Device Family is set to iPhone.
- Use Storyboards is not selected.
- Use Automatic Reference Counting is selected.
The project will be created and set up with specific files based on these initial settings.
3. Click Next and pick a location to store the project. Xcode will create a Hello folder under whichever folder you select.
4. Build and run the application by selecting Product | Run from the menu or by pressing Command-R. You should see iPhone simulator launch and the application running inside of it. The app currently displays a blank grey view (Figure C).Figure C
5. The app already supports multiple orientations. In order to test this in the simulator, you can select Hardware | Rotate Right from the menu. Notice that it will rotate into portrait and both landscape orientations.
6. Click the main project file from the file navigator to view a Summary of the project (Figure D); this allows you to set the Bundle Identifier, Version, supported Devices, Deployment Target, Initial Orientations, Icons, and Splash screens. All of these settings are specified in the Info.plist file, which you can get to by clicking the Info tab. However, most of the common things you will modify are in the Summary tab. I will skip over all of the settings that are available to your app, but you should learn them prior to submitting to the App Store.Figure D
7. Open the ViewController.xib file. This brings up the Interface Builder editor, which allows you to create your initial view. It should look similar to the grey view you saw when you ran the application. This is the initial view that gets loaded by the app. Make sure the Utilities panel is visible, and the Object library is displayed. Drag a Label into the view and resize it to fit most of the screen with a small margin. Click the Attributes Inspector and change the Text to Hello, Alignment to center, and Font size to 100. The label should look like Figure E.Figure E
8. Build and run in the simulator, and notice that our label appears (Figure F).Figure F
9. Rotate the simulator into landscape mode; you’ll notice that the label does not stay in the center once it rotates into a landscape orientation. You can fix that by opening the ViewController.xib file, clicking the label, and switching to the Size inspector. Locate Autosizing and notice that it is bound to the top and left sides of the view (Figure G).Figure G
9. Remove those settings in order to keep the label centered, and enable resizing of the width and height. Autosizing should look like Figure H.Figure H
10. Run the app in the simulator and then change the device orientation to landscape. Notice that it rotates and keeps the label perfectly center (Figure I).Figure I
That’s it! The classic Hello World app was implemented without coding, and we get the added bonus of supporting multiple orientations. In my next TechRepublic tutorial, you will do some coding to turn this application into a functioning clock.
- Dedicated Developers Takes Coveted Top 5 Spot in Atlanta iPhone App Developer Rankings!
- These iPhone apps reportedly sell your exact location
- iPhone apps blasted for selling your exact location
- Antitrust attorney K. Todd Wallace comments on the latest development in Apple iPhone apps antitrust litigation
- Find iPhone app solves a WLR burglary overnight
- How 2 Housewives Created The World's Most Popular Personality Test
- GoodFirms Highlights the list of Top 10+ Mobile App Development Companies Los Angeles for 2018
- iPhones with iOS 12 are vulnerable to a hack that bypasses lock screens
- Iran President's Phone 'Recently' Tapped, General Reveals After News of Donald Trump's Unsecured iPhones
- China Trolls Trump White House: Should Use Huawei Phones Instead of iPhones If Worried About Being Tapped
- iPhone XR makes the right trade-offs for a cheaper price than top-of-the-line XS
- Urban Airship Urges Companies to Adopt New App Notification Practices with Advancements Coming to iOS 12
- At World’s Largest Food Market, a Sip of Wine After a Night of Butchery
- The Inventor of the World Wide Web Plans to Start a New Internet to Take on Google and Facebook
- Bondi unveils post-Parkland reporting app, Trump tweets support
- World War II Intelligence Officer Gets Congressional Medal
- Macron Wants to Create 'French Islam' to Align Muslims With Secular Society
- Coca-Cola Considers Cannabis-Infused Drinks to Create 'Wellness Beverages'
- Legal Weed Is Creating Thousands of Jobs But Companies Struggle to Find Qualified Workers In Canada, Experts Say
- Six Arrested for Allegedly Creating a 'Far-Right Terrorist Organization'