要顯示在基礎的導航應用程序的登錄視圖,你應該嘗試以下操作:
你只需要修改你的RootViewController的是UIVeiwController代替的UITableViewController的子類,並修改XIB文件有一個正常的UIView作爲它的視圖而不是UITableView。
然後把下面的函數來設置的TabBar:用於處理按鈕單擊事件
-(void)setTabbar:(UIView *) view
{
UIButton *btn1,*btn2,*btn3,*btn4,*btn5,*btn6;
UIView *tabView;
tabView=[[UIView alloc]initWithFrame:CGRectMake(0, 375, 320, 44)];
btn1=[UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame=CGRectMake(0, 0, 53, 44);
btn1.tag=1;
[btn1 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateNormal];
[btn1 setImage:[UIImage imageNamed:@"b2.png"] forState:UIControlStateSelected];
[btn1 addTarget:self action:@selector(btnTabclick::) forControlEvents:UIControlEventTouchDown];
[tabView addSubview:btn1];
btn2=[UIButton buttonWithType:UIButtonTypeCustom];
btn2.frame=CGRectMake(53, 0, 53, 44);
btn2.tag=2;
[btn2 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateNormal];
[btn2 setImage:[UIImage imageNamed:@"b2.png"] forState:UIControlStateSelected];
[btn2 addTarget:self action:@selector(btnTabclick::) forControlEvents:UIControlEventTouchDown];
[tabView addSubview:btn2];
btn3=[UIButton buttonWithType:UIButtonTypeCustom];
btn3.frame=CGRectMake(106, 0, 53, 44);
btn3.tag=3;
[btn3 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateNormal];
[btn3 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateSelected];
[btn3 addTarget:self action:@selector(btnTabclick::) forControlEvents:UIControlEventTouchDown];
[tabView addSubview:btn3];
btn4=[UIButton buttonWithType:UIButtonTypeCustom];
btn4.frame=CGRectMake(159, 0, 55, 44);
btn4.tag=4;
[btn4 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateNormal];
[btn4 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateSelected];
[btn4 addTarget:self action:@selector(btnTabclick::) forControlEvents:UIControlEventTouchDown];
[tabView addSubview:btn4];
btn5=[UIButton buttonWithType:UIButtonTypeCustom];
btn5.frame=CGRectMake(214, 0, 54, 44);
btn5.tag=5;
[btn5 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateNormal];
[btn5 setImage:[UIImage imageNamed:@"b2.png"] forState:UIControlStateSelected];
[btn5 addTarget:self action:@selector(btnTabclick::) forControlEvents:UIControlEventTouchDown];
[tabView addSubview:btn5];
btn6=[UIButton buttonWithType:UIButtonTypeCustom];
btn6.frame=CGRectMake(266, 0, 55, 44);
btn6.tag=6;
[btn6 setImage:[UIImage imageNamed:@"b1.png"] forState:UIControlStateNormal];
[btn6 setImage:[UIImage imageNamed:@"b2.png"] forState:UIControlStateSelected];
[btn6 addTarget:self action:@selector(btnTabclick::) forControlEvents:UIControlEventTouchDown];
[tabView addSubview:btn6];
if (TAG==1)
{
[btn1 setSelected:YES];
}
if (TAG==2)
{
[btn2 setSelected:YES];
}
if (TAG==3)
{
[btn3 setSelected:YES];
}
if (TAG==4)
{
[btn4 setSelected:YES];
}
if (TAG==5)
{
[btn5 setSelected:YES];
}
if (TAG==6)
{
[btn6 setSelected:YES];
}
[view addSubview:tabView];
if ([btnArry count]!=0 || [btnArry retainCount]!=0)
{
[btnArry release];
}
btnArry=[[NSArray alloc]initWithObjects:btn1,btn2,btn3,btn4,btn5,btn6, nil ];
}
然後把下面的函數
-(IBAction)btnTabclick:(id)sender:(UIView*)view
{
TAG=[sender tag];
if (TAG==1) {
//code to handle click event
}else if(TAG==2){
//code to handle click event
}else if(TAG==3){
//code to handle click event
}else if(TAG==4){
//code to handle click event
}else if(TAG==5){
//code to handle click event
}else if(TAG==6){
//code to handle click event
}
}
把上面的代碼在應用程序委託文件後只需調用settabbar功能如下:
[((AppDelegate *)[[UIApplication sharedApplication]delegate]) setTabbar:self.view];
你需要接受的答案你前面的問題,令人沮喪的人把精力回答你的問題,如果你不能打擾接受他們的答案。 – 2011-12-15 11:18:38