Building a simple social networking application

In this recipe we will learn how to build the user interface for our social networking application project.

Getting ready

In this section, we will start by building the components that will comprise of the user interface for our application.

How to do it…

To begin, follow the simple steps as outlined in the given order:

  1. Launch Xcode from the /Xcode4/Applications folder.
  2. Choose Create a new Xcode project, or File | New Project.
  3. Select the Single View Application from the list of available templates.
  4. Click on the Next button to proceed to the next step in the wizard.
  5. Next, enter in SocialNetworkApp as the name for your project.
  6. Choose iPhone from under the Devices drop-down list.
  7. Ensure that the Use Storyboards checkbox has not been selected.
  8. Ensure that the Use Automatic Reference Counting and the Include Unit Tests checkboxes have not been selected.
  9. Next, click on the Next button to proceed to the next step in the wizard and specify the location where you would like to save your project.
  10. Then, click on the Create button to continue and display the Xcode workspace.

Now that we have created our SocialNetworkApp project, we can start building our user interface that will be responsible for allowing us to communicate with Facebook:

  1. Select the ViewController.xib files from the Project Navigator Window.
  2. From the Object Library, select and drag a UIToolbar object, and add this to our view and select the Item button located within our toolbar.
  3. From the Attributes Inspector section, change the Identifier property to Custom and change the value of Style to Bordered and the value of Title to Sign In.
  4. Create an outlet for this UIBarButtonItem, and name it loginButton.
  5. Create the action method for the Sign In button and name it loginButton.
  6. Add a flexible space bar button item next to the Sign In button.
  7. Add another UIBarButtonItem to the right of the flexible space bar button item and from the Attributes Inspector, change the Identifier property to Action.
  8. From the Object Library, drag a UIImageView object onto the view.
  9. Resize the UIImageView control so that it can hold a passport size photo.
  10. Next, create the outlet for this UIImageView, and name it imgPhoto.
  11. From the Object Library, drag a UITextView object onto the view.
  12. Resize the UITextView control so that it takes up the width of the View Controller.
  13. Next, create the outlet for this UITextView, and name it userInfoDetails.
  14. Save the SocialNetworkApp by choosing File | Save from the menu bar.
    How to do it…

If you have followed the steps correctly, the completed View Controller screen should look similar to the previous screenshot. Feel free to adjust your screen accordingly.

How it works...

In this recipe, we started by building our user interface for our SocialNetworkApp application that will enable us to log in and out of Facebook and post messages to our wall. In our next recipe, we will look at how to add the Facebook iOS SDK into our project, which allows us to communicate with the Facebook mobile development platform, and includes the necessary properties and methods that allows us to post messages to the current user's wall.

See also

  • The Adding the Facebook SDK and dependencies to your project recipe
  • The Using Xcode to create an iOS project recipe in Chapter 1, Getting and Installing the iOS SDK Development Tools
  • The Creating outlets to Interface Builder objects recipe in Chapter 1, Getting and Installing the iOS SDK Development Tools
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset