Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从UITabBarController对UITableViewController的模态演示_Ios_Swift_Uitabbarcontroller - Fatal编程技术网

Ios 从UITabBarController对UITableViewController的模态演示

Ios 从UITabBarController对UITableViewController的模态演示,ios,swift,uitabbarcontroller,Ios,Swift,Uitabbarcontroller,因此,根据标题,我试图从UITabBarController演示一个UITableViewController。如果你看我附加的视频,在第三个选项卡上,它显示了一个视图控制器。这就是我想要实现的 我已经找了一整天了,但是我试过了,但是没有用 这就是我目前的做法。我在第一个选项卡的视图控制器中添加了这行代码 self.tabBarController?.delegate = UIApplication.sharedApplication().delegate as? UITabBarContro

因此,根据标题,我试图从UITabBarController演示一个UITableViewController。如果你看我附加的视频,在第三个选项卡上,它显示了一个视图控制器。这就是我想要实现的

我已经找了一整天了,但是我试过了,但是没有用

这就是我目前的做法。我在第一个选项卡的视图控制器中添加了这行代码

self.tabBarController?.delegate = UIApplication.sharedApplication().delegate as? UITabBarControllerDelegate
这是在我的AppDelegate中

class AppDelegate: UIResponder, UIApplicationDelegate, UITabBarControllerDelegate {

    var window: UIWindow?

func tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool {
    if viewController is YourViewController {
        if let newVC = tabBarController.storyboard?.instantiateViewControllerWithIdentifier("YourVCStoryboardIdentifier") {
            tabBarController.presentViewController(newVC, animated: true, completion: nil)
            return false
        }
    }

    return true
}

func setStatusBarBackgroundColor(color: UIColor) {
    guard  let statusBar = UIApplication.sharedApplication().valueForKey("statusBarWindow")?.valueForKey("statusBar") as? UIView else {
        return
    }

        statusBar.backgroundColor = color
    }

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    setStatusBarBackgroundColor(UIColor.lightGrayColor())
    return true
}

当前的行为是什么?您还没有提到调试以查看是否应调用
shouldSelectViewController
?你的设置不寻常。您不应该在
AppDelegate
中执行此操作。我将创建一个继承
UITabBarController
的类,并在
viewdiload
@NightFury中设置委托它按照正常方式加载我的视图控制器的当前行为,并且它在此时不做任何事情all@grimfrog我正在根据我提供的链接进行设置。我确实调试了shouldSelectViewController,但是没有调用它。实际上,我也创建了一个新类并继承了主tabbar,但是它提供了相同的效果。当前的行为是什么?您还没有提到调试以查看是否应调用
shouldSelectViewController
?你的设置不寻常。您不应该在
AppDelegate
中执行此操作。我将创建一个继承
UITabBarController
的类,并在
viewdiload
@NightFury中设置委托它按照正常方式加载我的视图控制器的当前行为,并且它在此时不做任何事情all@grimfrog我正在根据我提供的链接进行设置。我确实调试了shouldSelectViewController,但是没有调用它。实际上,我也创建了一个新类并继承了主tabbar,但是它提供了相同的效果。