IT tutorials
 
Mobile
 

iphone Programming : Adding Missing Features (part 3) - Changing the Display Name, Enabling Rotation

1/8/2013 11:27:18 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

3. Changing the Display Name

The name displayed beneath your application icon on the iPhone home screen is, by default, the name of your Xcode project. However, only a limited number of characters are displayed before an ellipsis is inserted and your application name is truncated. This is fairly messy, and generally users don’t like it. Fortunately, you can change your application’s display name by editing the “Bundle display name” field in the application’s Info.plist file.

If you look at our City Guide application, you’ll notice that the display name is the same as our project name: “CityGuide”. While the name is not long enough to be truncated when displayed on the iPhone’s home screen, we might want it to be displayed as “City Guide” instead. Let’s make that change now.

Open the CityGuide project in Xcode and click on the CityGuide-Info.plist file to open it in the Xcode editor. Double-click on the Value field in the “Bundle display name” field and change the ${PRODUCT_NAME} macro to City Guide, as shown in Figure 7.

If you rebuild the application and deploy it in iPhone Simulator, you’ll notice that the name displayed below the City Guide application icon has changed from “CityGuide” to “City Guide”.

Figure 7. Setting the “Bundle display name” in the City Guide application’s Info.plist file


4. Enabling Rotation

Until now, all of the applications we have built in the book have been in portrait mode and would not rotate into landscape mode, as many iPhone applications do when the user rotates the phone. Enabling this functionality is actually amazingly easy. In your view controller class, add the following method:

- (BOOL)shouldAutorotateToInterfaceOrientation:
  (UIInterfaceOrientation)interfaceOrientation {
    // Return YES for all supported orientations
    return YES;
}

If you rebuild your application and rotate your device, or if you select HardwareRotate Left or HardwareRotate Right in the simulator, your UI will rotate into landscape mode. If you have multiple view controllers (such as RootController.m, CityController.m, and AddCityController.m), you need to add this method to each of them.


Note:

Although the shouldAutorotateToInterfaceOrientation: method was called in a timely fashion under the 2.0 SDK, this is not always the case under the 3.0 SDK. To ensure that you are (reliably) notified of changes in the device orientation, you should register for notification of orientation change messages.


However, the UI elements will also squash and stretch into the new orientation. You need to make sure that the individual UI elements can cope with their new sizes elegantly. You can do that in one of two ways:

  • Be careful when using the Size tab in the Inspector window in Interface Builder to make sure they stretch in the correct fashion. The easiest way to do this is to make use of the Autosizing, Alignment, and Placement sections in the Size tab.

  • Register for orientation change notifications and dynamically adapt your UI based on those events. For example, the built-in Calculator application has a different UI in portrait and landscape modes.

You can start generating orientation change notifications by calling this method of the UIDevice class (in the viewDidLoad: method of your view controller class):

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

When you are no longer concerned about orientation changes, you stop such notifications by calling this method:

[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];

After starting notifications, you must also register your class to receive such messages using the NSNotificationCenter class:

NSNotificationCenter *notificationCenter =
  [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
                    selector:@selector(handlerMethod:)
                    name:@"UIDeviceOrientationDidChangeNotification"
                    object:nil];

This would invoke the handlerMethod: selector (elsewhere in your view controller) in the current class when such a message was received:

-(void) handlerMethod:(NSNotification *)note {

     /* Deal with rotation of your UI here */
}
 
Others
 
- iphone Programming : Adding Missing Features (part 2) - Adding a Launch Image
- iphone Programming : Adding Missing Features (part 1) - Adding an Icon
- iphone Programming : Using Sensors - Accessing the Proximity Sensor
- Mobile Web Apps : Templating - Twitter Integration with Templating
- Mobile Web Apps : Ajax - Fetching HTML, Ajaxifying Links
- IPad : Working with Contacts - Adding a New Contact Right on Your iPad
- Bluetooth on the iPad : Bluetooth Stereo, Disconnect or Forget a Bluetooth Device
- BlackBerry Bold 9700 and 9650 Series : Fixing Problems - Web Browser Running Slowly, Automatic Memory Cleaning to Keep Running Smoothly
- BlackBerry Bold 9700 and 9650 Series : Fixing Problems - BlackBerry Running Slowly?
- Windows Phone 7 Advanced Programming Model : Working with Images on Windows Phone 7, The Windows Phone 7 Media Library
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us