Iphone 如何在iOs中将UIAbbarController添加到UIViewController
如何使用TabbarController推送Viewcontroller?在Viewcontroller的XIB中,我创建了UITabbarController。然后我按下这个ViewController,但它不显示为abbarcontroller。 这是我的代码: *Viewcontroller.h:Iphone 如何在iOs中将UIAbbarController添加到UIViewController,iphone,ios,objective-c,uiviewcontroller,uitabbarcontroller,Iphone,Ios,Objective C,Uiviewcontroller,Uitabbarcontroller,如何使用TabbarController推送Viewcontroller?在Viewcontroller的XIB中,我创建了UITabbarController。然后我按下这个ViewController,但它不显示为abbarcontroller。 这是我的代码: *Viewcontroller.h: @interface StatusViewController : UIViewController<UITabBarControllerDelegate> { IBOut
@interface StatusViewController : UIViewController<UITabBarControllerDelegate>
{
IBOutlet UITabBarController *tabBarController;
IBOutlet UIButton *UploadButton;
IBOutlet UIButton *ConvertorButton;
IBOutlet UIButton *CompletedButton;
}
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
感谢您的帮助如果您是初学者,最佳做法是在google中搜索最新的api示例,然后了解代码并创建自己的世界 1) 您可以从apple找到相关的示例代码
2) --这是自定义TabBarController(TweetieTabBar)的示例代码。如果您想在UIViewController类中使用UITabBarController,请使用下面的代码 UIViewController.h类-
@property (nonatomic, retain) UITabBarController *tab;
UIViewController.m类-
将此添加到ViewDidLoad方法中
self.tab=[[UITabBarController alloc]init];
// FirstViewController
First *fvc=[[First alloc]initWithNibName:nil bundle:nil];
fvc.title=@"First";
fvc.tabBarItem.image=[UIImage imageNamed:@"i.png"];
//SecondViewController
Second *svc=[[Second alloc]initWithNibName:nil bundle:nil];
svc.title=@"Second";
svc.tabBarItem.image=[UIImage imageNamed:@"im.png"];
//ThirdViewController
Third *tvc=[[Third alloc]initWithNibName:nil bundle:nil];
tvc.title=@"Third";
tvc.tabBarItem.image=[UIImage imageNamed:@"img.png"];
self.tab.viewControllers=[NSArray arrayWithObjects:fvc, svc, tvc, nil];
[self.view addSubview:self.tab.view];
这里的第一、第二和第三是三个不同的UIViewController。您不需要在选项卡上给出操作
它会起作用的…您在这里提出的问题是不可理解的..请让它正确?您可以动态更改您的rootview,您可以这样做。推动UITABBARCONTOLLERTANKS需要什么?我试过你的代码,它可以工作,但tabbaritem不在botton位置。我不知道为什么?好的。你正在为普通屏幕320*480创建项目吗?它不会显示320*568屏幕。你应该根据你的屏幕大小设置帧坐标..我看到你在拍摄,你肯定在使用iphone(视网膜4.0英寸)模拟器..self.tab=[[UITabBarController alloc]init];CGRect屏幕边界=[[UIScreen mainScreen]边界];if(screenBounds.size.height==568){//4英寸屏幕的代码//LoginButton.frame=CGRectMake(0,518,80,49);self.tab.view.frame=CGRectMake(0,0320568);}else if(screenBounds.size.height==1024){//ipad的代码}else{//3.5英寸屏幕的代码//LoginButton.frame=CGRectMake(0,430,80,49);self.tab.view.frame=CGRectMake(0,0320480);}但它不正确是的,它完全错了,伙计..你想在屏幕底部或顶部设置选项卡栏的位置。。????
self.tab=[[UITabBarController alloc]init];
// FirstViewController
First *fvc=[[First alloc]initWithNibName:nil bundle:nil];
fvc.title=@"First";
fvc.tabBarItem.image=[UIImage imageNamed:@"i.png"];
//SecondViewController
Second *svc=[[Second alloc]initWithNibName:nil bundle:nil];
svc.title=@"Second";
svc.tabBarItem.image=[UIImage imageNamed:@"im.png"];
//ThirdViewController
Third *tvc=[[Third alloc]initWithNibName:nil bundle:nil];
tvc.title=@"Third";
tvc.tabBarItem.image=[UIImage imageNamed:@"img.png"];
self.tab.viewControllers=[NSArray arrayWithObjects:fvc, svc, tvc, nil];
[self.view addSubview:self.tab.view];