IT tutorials

iPhone Developer : Working with View Controllers - Presenting a Custom Modal Information View

12/18/2012 5:56:20 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Modal view controllers slide onscreen without being part of your standard view controller stack. Modal views are useful for picking data or presenting information, tasks that might not match well to your normal hierarchy. Any view controller or navigation controller can present a modal controller:

[self presentModalViewController:[[[InfoViewController alloc] init]
    autorelease] animated:YES];

The controller that is presented can be either a view controller or navigation controller. Either way, it helps to provide a Done button to allow the user to dismiss the controller.Figure 1 shows a modal presentation built around a UIViewController instance. The navigation bar at the top of the view was added via a UINavigationBar instance, making this view especially easy to construct in Interface Builder.

Figure 1. This modal view is built using UIViewController with a UINavigationBar.

Normally, a navigation controller-based view requires two .xib files and extra work. Using the bar directly avoided the hassle and provided an elegant solution that mimics the normal look of a UINavigationController presentation.

Recipe 1 shows the two key pieces for this presentation. The presentation is done in the main view controller, with the presentation style set by a segmented control. The InfoViewController, that is, the class that was presented, handles dismissal. Its Done button was connected via IB to the doneReading method. This method asks the view controller’s parent to dismiss the modally presented view controller.

Recipe 1. Presenting and Dismissing a Modal Controller
// Presenting the controller
- (void) info
    int segment = [(UISegmentedControl *)self.navigationItem.titleView
    int styles[3] = {UIModalTransitionStyleCoverVertical,
    InfoViewController *ivc = [[[InfoViewController alloc] init]
    ivc.modalTransitionStyle = styles[segment];
    [self presentModalViewController:ivc animated:YES];


// Dismissing the controller
- (IBAction) doneReading
    [[self parentViewController]
- Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 3) - Using Touch
- Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 2) - Debugging in the Emulator, Debugging with a Device
- Windows Phone 8 : Writing Your First Phone Application - Adding Code (part 1) - Working with Events
- Windows Phone 8 : Designing with Blend
- Iphone Application : Implementing Location Services - Creating a Location-Aware Application (part 2) - Implementing the Location Manager Delegate
- Iphone Application : Implementing Location Services - Creating a Location-Aware Application (part 1)
- Iphone Application : Implementing Location Services - Understanding Core Location
- Windows Phone 8 : Creating a New Project (part 2) - XAML
- Windows Phone 8 : Creating a New Project (part 1) - Visual Studio
- Developing BlackBerry Tablet Applications : Permissions and Configuration Settings
Top 10
Technology FAQ
- Microsoft ebs security server configuration
- IIs7 on Windows server 2003
- How to Configure Failover Clusters With Win 2008 Server R2?
- Windows 2008 Network Load Balancing
- Windows Server 2008 - Group Policy Management - Remove Computer Management
- Remove shortcuts possibility in a web page or to put in favorite
- HTA Dynamic Drop Down List
- IIS host header and DNS
- VMware or MS Virtual Server?
- Adobe Acrobat 9 inserting tab pages
programming4us programming4us