开发者

Customising UITabBarItems in their controllers?

In previous applications I have customised my tabBarItems by overriding init (see below)

- (id)init {
    self = [super init];
    if(self) {
        UITabBarItem *tabBarItem = [self tabBarItem];
        [tabBarItem setTitle:@"ONE"];
    }
    return self;
}

After looking at the Xcode templates I am now thinking that I would be better to add this customisation to initWithNibName:bundle: instead.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bu开发者_高级运维ndle:nibBundleOrNil])) {
        UITabBarItem *tabBarItem = [self tabBarItem];
        [tabBarItem setTitle:@"ONE"];
    }
    return self;
}

does this make sense, it seems like it does to me, but I just wanted to check?

Gary


It depends on whether you load your controller from a Nib (xib) file or not (and so you do all the work programmatically in the init) I guess

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜