ios - 如何关闭滑动菜单并链接回选定的选项卡?

标签 ios objective-c tabbar

我有滑动菜单 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]; }];

    }

enter image description here

最佳答案

你可以试试

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/

相关文章:

ios - 匹配来自 IOS 和 OS X 的地址簿记录?

javascript - notification.confirm 回调不触发 phonegap iOS

javascript - iOS:使用本地 javascript 文件打开 UIWebView

ios - 计算游戏结束的节点

objective-c - 两个日期之间有多少个季度?

react-native - 标签下的 React Native Tab Bar 空白

ios - 检查拆分键盘

ios - 遍历已解析的数组

ios - 什么可能导致图像在标签栏 iOS 中看起来很难看?

ios - 基于警报选择的 Swift TabbarViewController 操作。 shouldSelect 和 didSelect 没有帮助