IT tutorials
 
Mobile
 

iPhone Developer : Navigating Between View Controllers

11/15/2011 3:57:22 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
In addition to providing menus, navigation controllers do the job they are designed to do: managing hierarchy as you navigate between views. Recipe 1 introduces the navigation controller as an actual navigation controller, pushing views on the stack.

An instance variable stores the current depth number, which is used to show the current level and decide whether to display a further push option. The maximum depth here is 6. In real use, you’d use more meaningful view controllers or contents. This sample demonstrates things at their simplest level.

The navigation controller automatically creates the Level 2 Back button shown in Figure 1 (left) as an effect of pushing the new Level 3 controller onto the stack. The rightmost button (Push 4) triggers navigation to the next controller by calling pushViewController: animated:. When pushed, the next Back button reads Level 3, as shown in Figure 1 (right).

Figure 1. The navigation controller automatically creates properly labeled Back buttons. After selecting the Push 4 button in the left interface, the navigation controller pushes the Level 4 view controller and creates the Level 3 Back button in the right interface.

Back buttons pop the controller stack for you. You do not need to program any popping behavior yourself. Note that Back buttons are automatically created for pushed view controllers but not for the root controller itself, as it is not applicable.

Recipe 1. Drilling Through Views with UINavigationController
@interface TestBedViewController : UIViewController
{
int depth;
}
@end

@implementation TestBedViewController
- (id) initWithDepth: (int) theDepth
{
self = [super init];
if (self) depth = theDepth;
return self;
}

- (void) push
{
TestBedViewController *tbvc = [[[TestBedViewController alloc]
initWithDepth:(depth + 1)] autorelease];
[self.navigationController pushViewController:tbvc animated:YES];
}

- (void) loadView
{
self.view = [[[NSBundle mainBundle] loadNibNamed:@"mainview"
owner:self options:nil] lastObject];
NSString *valueString = [NSString stringWithFormat:@"%d", depth];
NSString *nextString = [NSString stringWithFormat:@"Push %d",
depth + 1];

// set the title
self.title = [@"Level " stringByAppendingString:valueString];

// Set the main label
((UILabel *)[self.view viewWithTag:101]).text = valueString;

// Add the "next" bar button item. Max depth is 6
if (depth < 6) self.navigationItem.rightBarButtonItem =
BARBUTTON(nextString, @selector(push));
}
@end



 
Others
 
- iOS SDK : Basic SQLite Database Manipulation (part 3) - SQLite Binding, Inserting, Updating, and Deleting
- iOS SDK : Basic SQLite Database Manipulation (part 2) - Select
- iOS SDK : Basic SQLite Database Manipulation (part 1) - Opening the Database, Statements, Preparing Statements, and Executing Statements
- The Anatomy of a Mobile Site : PRIMARY SITE CONTENT (part 3) - Forms
- The Anatomy of a Mobile Site : PRIMARY SITE CONTENT (part 2) - Embedding Images and Media
- The Anatomy of a Mobile Site : PRIMARY SITE CONTENT (part 1) - Text, Typography& Pagination
- iPad Does Not Show Up in iTunes & Synchronization Problems
- iPad Troubleshooting : Re-register with Your iTunes Account
- XNA Game Studio 3.0 : Making a Prettier Clock with 3-D Text (part 2)
- XNA Game Studio 3.0 : Making a Prettier Clock with 3-D Text (part 1)
 
 
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