我目前在导航控制器、选项卡栏控制器中使用表视图。当我在表格视图的细节视图上时,我想在细节视图之间"滑动",所以我用UIViewAnimations实现了一个UISwipeGesture来向右/向左滑动。一切都正常,但我有一个小问题。。。当我在从表视图加载的详细信息视图上时,self.tabBarController元素在这里,我有我的选项卡栏,所以我可以在上面添加操作表。但当我滑动时,self-tabBarController现在为零。。。我不知道为什么。。。也许是因为导航控制器?
这是我的代码:
- (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];
}
];
}
}
我你可以帮我在刷完后找到我的标签栏:)?
在此处添加视图时:
[self.view addSubview:nextView.view];
UINavigation控制器对此一无所知,也不会为您设置navigationBar和tabBar属性。
您可以做的是让视图获得其超视图(将是self.view),然后向该视图请求tabBarController和来自该视图的tabBar。
我刚刚通过添加解决了我的问题
[self.ancient.navigationController popViewControllerAnimated:NO];
[self.ancient.navigationController pushViewController:nextView animated:NO];
在完成块上!