Monday, April 29, 2013

Tab Bar Application Part 4 ( Navigation )

                   
                                  Tab Bar Application Part 4 ( Navigation )

Step1
      
      Create a project by using previous tutorial

                  Tab Bar Application Part 1
                  Tab Bar Application Part 2
                  Tab Bar Application Part 3
         
Step 2

       add  a new class call "FirstView"



Step 3

  click the "FirstView.xib" file then change the UI

Step 4


  change the code in "FirstTabView.h" file

#import <UIKit/UIKit.h>
#import "FirstView.h" // import the header of the "FirstView"

@interface FirstTabView : UIViewController

-(IBAction)GotoFirst:(id)sender;

@end


Step 5

  implement the  " -(IBAction)GotoFirst:(id)sender; " method   in the "FirstTabView.m" class

-(IBAction)GotoFirst:(id)sender
{
   
    FirstView *first=[[FirstView alloc] initWithNibName:@"FirstView" bundle:nil];
    //Push detail view controller on to the stack
    [self.navigationController pushViewController:first animated:YES];
   
}




Step 6

add button to the  "FirstTabView.xib"









Step 7

Run Your App







Wednesday, April 24, 2013

Tab Bar Application Part 3 ( Add a login screen)

 Tab Bar Application Part 3 ( Add a login screen)

Step 1
    Create a Project by using  My Previous Tutorial Part 1 & Part 2
             
                 Tab Bar Application Part 1
                 Tab Bar Application Part 2
 Step 2

    create new class ... call " LoginView"  to your project


  design the " LoginView.xib " like this


Step 3

Click the  "AppDelegate.m"  and import the LoginView header

     

Step 4

change code like this... in  "AppDelegate.m " 

this is the method you have to change

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions


code : -


//
//  AppDelegate.m
//  TabBarExample
//
//  Created by Apple on 4/24/13.
//  Copyright (c) 2013 Dhanushka Adrian. All rights reserved.
//

#import "AppDelegate.h"

#import "ViewController.h"


#import "FirstTabView.h"
#import "SecondTabView.h"
#import "ThirdTabView.h"

#import "LoginView.h"   

@implementation AppDelegate

- (void)dealloc
{
    [_window release];
    [_viewController release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
   
   
    FirstTabView   *firstTab   =[[FirstTabView alloc]initWithNibName:@"FirstTabView" bundle:nil];   
    SecondTabView  *secondTab  =[[SecondTabView alloc]initWithNibName:@"SecondTabView" bundle:nil];
    ThirdTabView   *thirdTab   =[[ThirdTabView alloc]initWithNibName:@"ThirdTabView" bundle:nil];
    ViewController *fourthTab  =[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil]; 
   
    UINavigationController *nav1  =[[UINavigationController alloc] initWithRootViewController:firstTab];
    UINavigationController *nav2  =[[UINavigationController alloc] initWithRootViewController:secondTab];
    UINavigationController *nav3  =[[UINavigationController alloc] initWithRootViewController:thirdTab];
    UINavigationController *nav4  =[[UINavigationController alloc] initWithRootViewController:fourthTab];
   
    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4, nil];
   
   
 
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
   
    // add this code
    LoginView *logViewController = [[LoginView alloc] initWithNibName:@"LoginView" bundle:nil];
   
    [self.window addSubview:_tabBarController.view];

    //add this code
    [self.tabBarController presentModalViewController:logViewController animated:YES];
   
   
   
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
   
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
   
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
}

- (void)applicationWillTerminate:(UIApplication *)application
{
   
}

@end

Step 5

click the "LoginView.h"



Add a method for login like this...

//  LoginView.h
//  TabBarExample
//
//  Created by Apple on 4/24/13.
//  Copyright (c)Dhanushka Adrian. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface LoginView : UIViewController


-(IBAction)Login:(id)sender;

@end

Step 6


click the  "LoginView.m"

type  this metod in  "LoginView.m"....



-(IBAction)Login:(id)sender{

    [self dismissModalViewControllerAnimated:YES];

}

Step 7

click the "LoginView.xib"
right click the file owner 








Step 8

 Run your App