ios - 如何在选项卡之间切换并直接显示推送的 View Controller ?

标签 ios uitabbarcontroller xcode7 pushviewcontroller

这是我的代码:

  VideoDetailViewController *VideoDetailVC = [self.storyboard instantiateViewControllerWithIdentifier:@"VideoDetailViewController"];

  UINavigationController * navigationController = (UINavigationController *) [[self tabBarController] selectedViewController];

  [self.tabBarController setSelectedIndex:0];

  [navigationController pushViewController:VideoDetailVC animated:YES];

我正在选项卡栏的第二个索引中编写此代码。我想直接进入视频详细信息屏幕,它是选项卡栏零索引的 subview Controller 。一切正常,但我看到的是:它显示了一个父 View Controller ,它是选项卡栏的零索引。一秒钟后,它会推送到视频详细信息屏幕。我只是不想显示零索引。解决办法是什么?帮助将不胜感激。

编辑:

#import "TWPhotoCollectionViewCell.h"

@implementation TWPhotoCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.imageView = [[UIImageView alloc] initWithFrame:self.bounds];
        self.imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        self.imageView.layer.borderColor = [UIColor blueColor].CGColor;
        [self.contentView addSubview:self.imageView];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    [super setSelected:selected];

    self.imageView.layer.borderWidth = selected ? 2 : 0;
}

@end

最佳答案

替换下一行

  [navigationController pushViewController:VideoDetailVC animated:YES];

  [navigationController pushViewController:VideoDetailVC animated:NO];

它可能会解决您的问题。

关于ios - 如何在选项卡之间切换并直接显示推送的 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37541941/

相关文章:

json - 处理Swift 2.0 Google Maps Json时出错

ios - AudioKit AKSequencer 不会在 iOS 10 上循环

为 UiTableview 安排多个操作的 iOS 最佳实践

iOS 9 多行标签在集合可重用标题 View 中自动布局不起作用

uitabbarcontroller - 如何更改 iOS 7 中 tabBarItems 的文本和图标颜色?

ios - 从界面构建器为子标签栏 Controller 设置导航栏标题

ios - Spotlight 搜索 - 深层链接集成

ios - 在 ios objective c 中通过相机检测物体的速度

ios - Xcode 4.2 是否兼容 OS4 和 iOS5?

ios - 检查应用内支付项目是否已购买