我有滑动菜单 View Controller ,第一项是“主页”选项。我想要做的是,当我单击“主页”选项时,应用程序将重定向到第一个选项卡,即主页,即使在类别选项卡上也是如此。
现在,当我单击“主页”选项时,只有滑动菜单会隐藏,但选项卡仍保留在类别选项卡中
下面是我在菜单 View Controller 中的示例代码:-
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 0) { // HOW CAN I CLICK ON MENU ITEM 1 AND LINK BACK TO TAB NUMBER 1?
[self dismissViewControllerAnimated:YES completion:^{
[self.tabBarController setSelectedIndex:0]; }];
}
最佳答案
你可以试试
if (indexPath.row == 0) {
[self dismissViewControllerAnimated:YES completion:^{
UITabBarController*roo = (UITabBarController*)[UIApplication sharedApplication].keyWindow.rootViewController;
roo.selectedIndex = 0;
}];
}
关于ios - 如何关闭滑动菜单并链接回选定的选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49735430/