IOS實現界面切換

//代理類代碼

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

{

    self.window = [[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]]autorelease];

    // Override point for customization after application launch.

    self.window.backgroundColor = [UIColorwhiteColor];

    [self.windowmakeKeyAndVisible];

    

    RootViewController *rootViewController=[[RootViewControlleralloc]init];

   UINavigationController *uiNavigationController=[[UINavigationControlleralloc]initWithRootViewController:rootViewController];

   self.window.rootViewController=uiNavigationController;

    

    return YES;

}



//UIViewController代碼

-(void) loadView{

    

    UIView *baseView=[[UIViewalloc]initWithFrame:[[UIScreenmainScreen]applicationFrame]];

    baseView.backgroundColor=[UIColororangeColor];

   self.view=baseView;

    [baseViewrelease];

   

   UIButton *btnShowSecond=[[UIButtonalloc]initWithFrame:CGRectMake(100,100,50, 20)];

    [btnShowSecond setTitle:@"show"forState:UIControlStateNormal];

    [btnShowSecond addTarget:selfaction:@selector(showVC)forControlEvents:UIControlEventTouchUpInside];

    //btnShowSecond.backgroundColor=[UIColor blueColor];

    [self.viewaddSubview:btnShowSecond];

    

}


-(void)showVC{

    SecondViewController *secondViewController=[[SecondViewControlleralloc]init];

    [self.navigationControllerpushViewController:secondViewControlleranimated:YES];

    [selfrelease];

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章