2011-03-21 77 views
0

你能告訴我如何在TTTabItem選項卡上打開UIViewController嗎?當點擊TTTabIcon時打開UIViewController

URL映射在應用程序的委託完成的:

TTNavigator* navigator = [TTNavigator navigator]; 
navigator.supportsShakeToReload = YES; 
navigator.persistenceMode = TTNavigatorPersistenceModeAll; 

TTURLMap* map = navigator.URLMap; 
[map from:@"*" toViewController:[TTWebController class]]; 
[map from:@"tt://mannschaft" toViewController:[MannschaftController class]]; 

然後在我的視圖控制器我已經成功地將我的TTTabSTrip:

CGRect applicationFrame = [UIScreen mainScreen].applicationFrame; 

self.view = [[[UIView alloc] initWithFrame:applicationFrame] autorelease]; 
self.view.backgroundColor = TTSTYLEVAR(tabTintColor); 

_tabBar = [[TTTabStrip alloc] initWithFrame:CGRectMake(0, 0, applicationFrame.size.width, 41)]; 
_tabBar.tabItems = [NSArray arrayWithObjects:[[[TTTabItem alloc] initWithTitle:@"Anno 1834"] autorelease], nil]; 
[self.view addSubview:_tabBar]; 

如何我現在用開TTTabStrip低於其他的UIViewController TTURLMap?

感謝,doonot

回答

0

好吧,我必須先設置我的視圖控制器爲委託:

- (void)loadView { 
    CGRect applicationFrame = [UIScreen mainScreen].applicationFrame; 

    self.view = [[[UIView alloc] initWithFrame:applicationFrame] autorelease]; 
    self.view.backgroundColor = TTSTYLEVAR(tabTintColor); 

    _tabBar = [[TTTabStrip alloc] initWithFrame:CGRectMake(0, 0, applicationFrame.size.width, 41)]; 
    _tabBar.tabItems = [NSArray arrayWithObjects:[[[TTTabItem alloc] initWithTitle:@"Ajax Wälläbärg"] autorelease], nil]; 
    _tabBar.delegate = self; 
    [self.view addSubview:_tabBar]; 
} 

然後,如果你點擊一個TTabItem,委託調用這個函數:

- (void)tabBar:(TTTabBar*)tabBar tabSelected:(NSInteger)selectedIndex { 
     TTTabItem *tabItem = [tabBar.tabItems objectAtIndex:selectedIndex]; 
     NSLog(@" tabItem:%@, tabItem.title::%@", tabItem, tabItem.title); 

     if(selectedIndex == 0){ 
      UIViewController* viewController = [[TTNavigator navigator] viewControllerForURL:@"tt://ajax"]; 
      [self.view addSubview:viewController.view]; 
      [self.view addSubview:_tabBar]; 
     } 
    } 

列表中的第一項當然是索引爲0的項目。現在您可以在應用程序委託中定義URL映射。例如TT:// AJAX卡列斯的SponsorController:

UIViewController* viewController = [[TTNavigator navigator] viewControllerForURL:@"tt://ajax"]; 

AJAX是在應用程序委託定義:

TTNavigator* navigator = [TTNavigator navigator]; 
navigator.supportsShakeToReload = YES; 
navigator.persistenceMode = TTNavigatorPersistenceModeAll; 

TTURLMap* map = navigator.URLMap; 
[map from:@"*" toViewController:[TTWebController class]]; 
[map from:@"tt://mannschaft" toViewController:[MannschaftController class]]; 
[map from:@"tt://ajax" toViewController:[SponsorController class]]; 

我希望helpes。真的很糟糕,幾乎沒有任何示例或教程。歡呼聲

相關問題