2012-09-04 18 views
0

我目前在導航控制器內部使用了一個tableview,它位於標籤欄控制器內部。當我在表格視圖的細節視圖中,我想要在細節視圖之間「滑動」,所以我實現了UIViewAnimations向左/向右滑動的UISwipeGesture。 一切工作,但我有一個小問題...當我在從表視圖加載的詳細信息視圖,self.tabBarController元素在這裏,我有我的標籤欄,所以我可以在它上面添加一個動作表。但是當我刷卡時,self.tabBarController現在是零...我不知道爲什麼...也許是因爲導航控制器?tabBarController在更改視圖時設置爲nil,但始終在窗口中

這裏是我的代碼:

- (id) init 
{ 
    if (self = [super init]) { 
     CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame]; 
     UIScrollView *scrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, fullScreenRect.size.width, 367.)]; 
     scrollView.contentSize=CGSizeMake(320,100); 
     scrollView.delegate = self; 
     self.view=scrollView; 
     self.myView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 367.)]; 
     self.ButtonSizeM.tag = 0; 
     self.ButtonSizeP.tag = 0; 
     self.ContentIV = [[UIImageView alloc] init]; 
    } 
    return self; 
} 

- (void) handleSwipeLeft { 
    if (!((self.ancient.tableView.indexPathForSelectedRow.section == ([self.ancient numberOfSectionsInTableView:self.ancient.tableView] - 1)) && (self.ancient.tableView.indexPathForSelectedRow.row == [self.ancient tableView:self.ancient.tableView numberOfRowsInSection:(self.ancient.tableView.indexPathForSelectedRow.section)]-1))) 
    { 
     NSIndexPath *whereToGo; 
     if (self.ancient.tableView.indexPathForSelectedRow.row == [self.ancient tableView:self.ancient.tableView numberOfRowsInSection:(self.ancient.tableView.indexPathForSelectedRow.section)]-1) { 
      whereToGo = [NSIndexPath indexPathForRow:0 inSection:(self.ancient.tableView.indexPathForSelectedRow.section)+1]; 
     } 
     else { 
      whereToGo = [NSIndexPath indexPathForRow:(self.ancient.tableView.indexPathForSelectedRow.row)+1 inSection:self.ancient.tableView.indexPathForSelectedRow.section]; 
     } 

     CCFASimpleDetail *nextView = [[CCFASimpleDetail alloc] init]; 
     nextView = [self.ancient tableView:self.ancient.tableView prepareViewForIndexPath:whereToGo]; 
     [nextView performSelectorOnMainThread:@selector(affichageEnPlace) withObject:nil waitUntilDone:YES]; 

     float width = self.myView.frame.size.width; 
     float height = self.myView.frame.size.height; 

     [nextView.view setFrame:CGRectMake(width, 0.0, width, height)]; 

     [self.view addSubview:nextView.view]; 
     [UIView animateWithDuration:0.5f delay:0 options:UIViewAnimationCurveEaseInOut animations:^{ 
       [nextView.view setFrame:self.view.frame]; 
       [self.myView setFrame:CGRectMake(-width, 0.0, width, height)]; 
      } completion:^(BOOL finished) { 

       [self.myView removeFromSuperview]; 
       [self.ancient.tableView selectRowAtIndexPath:whereToGo animated:NO scrollPosition:UITableViewScrollPositionTop]; 
      } 
     ]; 
    } 
} 

我能不能幫我找刷卡:)後,我的標籤欄?

+0

你爲什麼要調用'performSelectorOnMainThread:...'?所有這些都應該在主線程中完成。 –

+0

好吧,不需要它,是的 –

回答

0

我只是解決了我的問題,通過完成塊上添加

[self.ancient.navigationController popViewControllerAnimated:NO]; 
[self.ancient.navigationController pushViewController:nextView animated:NO]; 

0

當您添加這裏的觀點:

[self.view addSubview:nextView.view]; 

的UINavigation控制器不知道這件事情,並不會爲你設置的導航欄河畔的TabBar屬性。

你可以做的是讓視圖得到它的超級視圖(這將是self.view),然後從那個視圖中獲取tabBarController和tabBar。

相關問題