1

大家好,我有 5 个带有 if 语句的 xib 文件:

enter code here
if(results == @"1")
{
    //open xib1
}else if(results == @"2")
{
    //Open xib2
}else if(results ==@"3"){
    //Open xib3
}else if(results ==@"4"){
    //open xib4
}else if(results ==@"5"){
    //open xib5
}

我不知道如何打开新的 xib 并关闭旧的 xib,我对目标 c 很抱歉。抱歉,这是针对 iPad 的,我想我是打开一个新的 xib 还是在主要的顶部显示一个 xib 都没有关系。

谢谢!

所以这会起作用吗?

if(results == @"1")
{
    NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"Results1" owner:self options:nil];
    UIView *aView = [nibObjs objectAtIndex:0];
    self.view = aView;
}else if(results == @"2")
{
    NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"Results2" owner:self options:nil];
    UIView *aView = [nibObjs objectAtIndex:0];
    self.view = aView;
}else if(results ==@"3"){
    NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"Results3" owner:self options:nil];
    UIView *aView = [nibObjs objectAtIndex:0];
    self.view = aView;
}else if(results ==@"4"){
    NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"Results4" owner:self options:nil];
    UIView *aView = [nibObjs objectAtIndex:0];
    self.view = aView;
}else if(results ==@"5"){
    NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"Results5" owner:self options:nil];
    UIView *aView = [nibObjs objectAtIndex:0];
    self.view = aView;
}
4

0 回答 0