开发者

Customising UITabBarItems in their controllers?

开发者 https://www.devze.com 2023-01-15 04:01 出处:网络
In previous applications I have customised my tabBarItems by overriding init (see below) - (id)init { self = [super init];

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

精彩评论

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