开发者

Three20 & TabBarController

开发者 https://www.devze.com 2023-02-11 07:18 出处:网络
I\'m stuck on something. I\'m using three20 and the TTTNavigator example. Where I can find a TabBarController that is using :

I'm stuck on something.

I'm using three20 and the TTTNavigator example. Where I can find a TabBarController that is using :

[self setTabURLs:[NSArray arrayWithObjects:@"tt://crush",
                                               @"tt://crushes",
                                               nil]];

to create each tab.

Ok until here all is ok, my problem is that I have all my tabs without title and image. I know how to set individual when it loads the view controller inside - (void)viewDidLoad :

    self.title = @"crush";
    UIImage* image = [UIImage imageNamed:self.title];
    self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self开发者_如何学Python.title image:image tag:0] autorelease];

but this is a problem because when you init the app all the tabs except the selected are empty.

Any suggest on how to implement that.


Ok I've resolved, I used the -init method of each view controller.. like usually... but what I need to change was :

[self setTabURLs:[NSArray arrayWithObjects:@"tt://crush/1",
                                               @"tt://crushes/2",
                                               nil]];

And in the map :

[map from:@"tt://crush/(init)" toViewController:[MakeCrushViewController class]];
[map from:@"tt://crushes/(init)" toViewController:[MyCrushesViewController class]]; 

for me right now it looks pretty weird.. but ok is working, don't ask me why you need to set 1 and 2 before the links.. if I set 1 on each it crashes...


This guy had an answer to this question in this blog post.1

Basically, within your tab view controller, just access the your view controllers like you would without three20. In your tab view controller implimentation file

-(void)viewDidLoad{
[super viewDidLoad];

NSArray *tabs =  [self viewControllers];

UIViewController *home = [tabs objectAtIndex:0];

home.tabBarItem.image = [UIImage imageNamed:@"redo.png"];

UIViewController *activities = [tabs objectAtIndex:1];
activities.tabBarItem.image = [UIImage imageNamed:@"restart.png"];
UIViewController *map = [tabs objectAtIndex:2];
map.tabBarItem.image = [UIImage imageNamed:@"lock.png"];
}
0

精彩评论

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

关注公众号