我目前正在开发有4个选项卡的选项卡应用程序。当我选择其中一个选项卡时,我想要的行为就像Instagram点击"相机选项卡"时的行为一样,我通过添加以下代码实现了这一点。但当我按下标签时;它首先显示一个黑屏,然后显示下面的视图。如何避免不显示黑屏?
override func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem) {
if item.title == "More" {
let storyboard = UIStoryboard(name: "Main", bundle: nil);
let moreView = storyboard.instantiateViewControllerWithIdentifier("moreView") as! MoreView;
moreView.modalPresentationStyle = UIModalPresentationStyle.FullScreen;
self.presentViewController(moreView, animated: true, completion: nil)
}
}
试试这个:
var next=self.storyboard?。instantiateViewControllerWithIdentifier("moreView")为!MoreView
代替:let storyboard=UIStoryboard(名称:"Main",bundle:nil);
给你要展示的课涂上背景色self.view.backgroundColor=UIColor.whiteColor()