开发者

Loading Tab Bar in the second view

开发者 https://www.devze.com 2023-02-11 07:44 出处:网络
Hi 开发者_开发问答I have been searching a solution to this problem for many days but cant seem to find the answer. In iphone I want a login view, as the first view, which will then lead to a tab ba

Hi

开发者_开发问答I have been searching a solution to this problem for many days but cant seem to find the answer. In iphone I want a login view, as the first view, which will then lead to a tab bar view. How do i implement this???

Thanks in advance


I think turning your login view into a modal view is what you need.

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html


Turning your login view into a modal view as Dirty Henry suggests is probably a good idea from a UI design standpoint, but if you just want to add a UITabBar to a view, you can do so in interface builder. Just put the tab bar in the view where you want it, and set that view's controller as the tab bar's delegate. You'll have to respond to selections of the tab bar items yourself, but this is not hard.


Try this

 self.hidesBottomBarWhenPushed = YES;

start a tabbar based app and try this in viewDidLoad.


   - (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"Tabbar created");


tab=[[UITabBarController alloc]init];
tab.view.frame=CGRectMake(0, 0, 320,460);

tab.delegate=self;

BSheepViewController *home=[[BSheepViewController alloc]init];
home.tabBarItem.image=[UIImage imageNamed:@"home.png"];
home.tabBarItem.title=@"Home";
UINavigationController *HomeNav=[[[UINavigationController alloc]init]autorelease];;
[HomeNav pushViewController:home animated:YES];
    //UINavigationController *HomeNav=[[[UINavigationController alloc]initWithRootViewController:home]autorelease];
    //[self.navigationController pushViewController:home animated:YES];
[home release];

    tab.viewControllers = [NSArray arrayWithObjects:HomeNav, nil];

tab.selectedIndex=bval;

[self.navigationController pushViewController:tab animated:YES];

}

use this type of code in TabBar Controller. in your Login View U should write like

   -(void)viewWillAppear:(BOOL)animated{

[self performSelector:@selector(fade)];
NSLog(@"%@",self.navigationController);

[self.navigationController setNavigationBarHidden:YES];

button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.showsTouchWhenHighlighted=YES;
button1.frame = CGRectMake(30,60,48,48);
[button1 addTarget:self action:@selector(Articles:) forControlEvents:UIControlEventTouchUpInside];
// [button1 setBackgroundImage:b1 forState:UIControlStateNormal];

[image2 addSubview:button1];
[image2 bringSubviewToFront:button1];
[image2 setUserInteractionEnabled:YES];
button1.tag=1;

  }

 -(void)Articles:(id)sender{
NSLog(@"Articles fired");   
TabBar *tab=[[TabBar alloc]initWithNibName:@"TabBar" bundle:nil];
tab.bval=button1.tag;
[self.navigationController pushViewController:tab animated:YES];
[tab release];
   }

u should push your tabbar view using navigation controller in Login View, in Tabbar Controller you should also navigation controller . its working for me. let me know if you dont find still.

0

精彩评论

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