我有一个自定义标签栏,添加了基于索引标记选择的UIView的子视图。
- (IBAction)onTabSelectionChange:(id)sender {
UIButton *btn = (UIButton*)sender;
previousIndex = currentIndex;
currentIndex = btn.tag;
if (btn.tag == previousIndex){
// scroll to top of previousIndex view
} else {
if (previousIndex != 0){
UIButton *btnpreviousIndex = (UIButton*)[tabView viewWithTag:previousIndex];
if (btnpreviousIndex != nil && previousIndex != -1){
[btnpreviousIndex setSelected:NO];
}
[btn setSelected:YES];
}
}
appDelegate.currentTab = currentIndex;
switch (currentIndex) {
case TABHOME: {
UINavigationController *navController = [appDelegate.arrViewControllers objectAtIndex:0];
navController.navigationBarHidden = YES;
[navController popToRootViewControllerAnimated:NO];
[self presentThisView: navController];
}
break;
case TABTIMELINE: {
UINavigationController *navController = [appDelegate.arrViewControllers objectAtIndex:1];
[self presentThisView: navController];
}
break;
case TABNOTIFICATION: {
self.badgeLabel.hidden = YES;
UINavigationController *navController = [appDelegate.arrViewControllers objectAtIndex:2];
[self presentThisView: navController];
break;
}
case TABMISCELLANEOUS: {
UINavigationController *navController = [appDelegate.arrViewControllers objectAtIndex:3];
[self presentThisView: navController];
break;
}
default:
break;
}
}
如何检索当前视图以将其滚动到顶部?
任何帮助将不胜感激。谢谢!