开发者

How to show login-controller just before the tab-bar application launch?

开发者 https://www.devze.com 2023-04-12 18:49 出处:网络
Hi, I have done a tab-bar application in iphone/ipad. After completing every thing the client wants a login-controller which the user have to login to enter the first view.The first view a singleview

Hi, I have done a tab-bar application in iphone/ipad. After completing every thing the client wants a login-controller which the user have to login to enter the first view.The first view a singleview that contains signin button and signup button,this view must be the first view,the user tap the signin it redirect to the signin page means the loginpage. After the login the user have to enter the first view of the tabbarapp. I tried this code in appDidFinishLaunching

RootViewController  *log = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    [window addSubview:tabController.view];
    [window addSubview:log.view];
    [window makeKeyAndVisible];

rootviewcontroller is the singin signup button view,i got this view in my app launch.But when i enter the singin ,it wont redirect to the singin or login page.My code for this is

pagesignIn *secondViewController = [[pagesignIn alloc] 
                                               initWith开发者_如何学CNibName:@"pagesignIn" 
                                               bundle:nil];

    [UIView beginAnimations:@"flipping view" context:nil];
    [UIView setAnimationDuration:1];
    //[UIView setAnimationCurve:UIViewAnimationTransitionFlipFromLeft];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                           forView:[[self navigationController] view] cache:YES];

    [self.navigationController pushViewController:secondViewController animated:YES ];
    [UIView commitAnimations];

But nothing comes in action, then I put this [self.view removeFromSuperview]; to the above code,now I got the button action but it did-not redirect to the sign-in page,but it redirected to the first page in tab-bar app.What will I do to go tot sign-in page after clicking the sign-in button? please help me. Thanks in advance.


I guess that your log-ViewController does not have an NavigationController. In your code self.navigationController is nil and all method calls on nil will do nothing.

try this:

RootViewController  *log = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
//create a new navigationcontroller
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:log];

[window addSubview:tabController.view];
[window addSubview:navVC.view]; //now add the navigationcontroller instead of the log-vc
[window makeKeyAndVisible];
[navVC release];
[log release];

But I advise you to use a modal-viewcontroller. It is much simpler (you dont have to play with subviews of the window for instance) and leads to better understanding of the user that there are two different views.


You should use modal view controller thats correct.

Change iPhone splash screen time

Refer to this link create your own login view controller class and replace the splash screen object with your login controller object. After dissmissing the login controller add your tab controller.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号