这是我的代码:
VideoDetailViewController *VideoDetailVC = [self.storyboard instantiateViewControllerWithIdentifier:@"VideoDetailViewController"];
UINavigationController * navigationController = (UINavigationController *) [[self tabBarController] selectedViewController];
[self.tabBarController setSelectedIndex:0];
[navigationController pushViewController:VideoDetailVC animated:YES];
我正在使用tabbar的第二个索引编写此代码。我想直接转到视频详细信息屏幕,这是tabbar的零索引的子视图控制器。一切正常,但我看到的是:它显示了一个父视图控制器,它是tabbar的零索引。一秒钟后,它会进入视频详细信息屏幕。我只是不想显示零指数。解决办法是什么?帮助将不胜感激。
编辑:
#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
答案 0 :(得分:1)
替换下面的行
[navigationController pushViewController:VideoDetailVC animated:YES];
使用
[navigationController pushViewController:VideoDetailVC animated:NO];
它可以解决您的问题。