简体   繁体   English

在connectionDidFinishLoading请求后选择其他xib

[英]Choose different xib after connectionDidFinishLoading request

After connectionDidFinishLoading I would like to dynamically choose a different xib if the data is more then one item. connectionDidFinishLoading之后,如果数据多于一项,我想动态选择其他xib。 Is that possible? 那可能吗? The method is called after my request comes back. 在我的请求返回后,将调用该方法。 However it keeps loading the original xib that has this class assigned to it through interface builder and crashes. 但是,它会继续加载通过接口构建器为其分配了此类的原始xib并崩溃。 The original xib its using is called TeamPoolViewController . 它使用的原始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;
    }
}

What I would do: 我会做什么:

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

But, be advised: the poolsView will not be ready until it's unarchived from xib, it's not ready immediately when you load it from xib via initWithNibName:bundle: You will be advised when it's ready in PoolsViewController awakeFromNib: 但是,建议:直到从xib取消存档后,poolsView才准备就绪;通过initWithNibName:bundle从xib加载它时,它还没有立即准备就绪:在PoolsViewController中,建议您准备好awakeFromNib:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM