在connectionDidFinishLoading请求后选择不同的xib

时间:2015-01-17 15:41:54

标签: ios objective-c iphone xcode xib

connectionDidFinishLoading之后,如果数据超过一个项目,我想动态选择不同的xib。那可能吗?我的请求回来后调用该方法。但是它会继续加载通过接口构建器和崩溃为其分配了此类的原始xib。其使用的原始xib称为TeamPoolViewController

- (NSMutableArray*) loadTableView {
    NSMutableArray *pools = [Pool getPools:[super parseResponse]];

    if([pools count] == 0)
        return pools;

    if([pools count] == 1)
    {
         self.view = [[NSBundle mainBundle] loadNibNamed:@"PoolsViewController" owner:self options:nil][0];
        return pools;
    }
    else
    {
        Pool *pool = [pools objectAtIndex:0];
        self.navigationItem.title = pool.name;
        return pool.poolTeams;
    }
}

1 个答案:

答案 0 :(得分:0)

我会做什么:

PoolsViewController *poolsViewController = [PoolsViewController initWithNibName:@"PoolsViewController" bundle:nil];
NSView *poolsView = [poolsViewController view];

但是,请注意:poolView在从xib取消归档之前不会就绪,当你从xib通过initWithNibName加载它时,它还没有准备就绪:bundle: 在PoolsViewController awakeFromNib:

中,它会被告知