Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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 为什么自定义UINavigationController不显示?_Ios_Objective C_Swift_Cocoa Touch - Fatal编程技术网

Ios 为什么自定义UINavigationController不显示?

Ios 为什么自定义UINavigationController不显示?,ios,objective-c,swift,cocoa-touch,Ios,Objective C,Swift,Cocoa Touch,我正在制作一个自定义UINavigationController,它使用自定义UICollectionViewController作为其根视图控制器。所有这些都是通过编程完成的,因为我正在将所有这些控制器装配到一个框架中(我使用的是iOS8)。但是,当我尝试使用presentViewController:animated:和navigationController?显示UINavigationController时,它没有显示,如果显示,它应该覆盖的视图控制器冻结。以下是自定义UINavigat

我正在制作一个自定义
UINavigationController
,它使用自定义
UICollectionViewController
作为其根视图控制器。所有这些都是通过编程完成的,因为我正在将所有这些控制器装配到一个框架中(我使用的是iOS8)。但是,当我尝试使用
presentViewController:animated:
navigationController?显示
UINavigationController
时,它没有显示,如果显示,它应该覆盖的视图控制器冻结。以下是自定义
UINavigationController
的代码:

public class BlahBlahCustomNavigationController: UINavigationController {

    var rootCollectionViewController: BlahBlahCustomCollectionViewController!

    public init() {
        rootCollectionViewController = BlahBlahCustomCollectionViewController()
        super.init(rootViewController: rootCollectionViewController)
    }

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nil, bundle:nil)

        rootCollectionViewController = BlahBlahCustomCollectionViewController()
        setViewControllers([rootCollectionViewController], animated: false)
    }

    required public init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    //No code other than above
}
public class BlahBlahCustomCollectionViewController {
    //...

    public init() {
        let flowLayout = UICollectionViewFlowLayout()
        flowLayout.minimumInteritemSpacing = 1
        flowLayout.minimumLineSpacing = 1
        flowLayout.itemSize = CGSize(width: 75, height: 75)
        super.init(collectionViewLayout: flowLayout)

        collectionView!.backgroundColor = UIColor.whiteColor()
        title = ""
    }

    required public init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    //...
}
下面是BlahBlahCustomCollectionViewController的代码:

public class BlahBlahCustomNavigationController: UINavigationController {

    var rootCollectionViewController: BlahBlahCustomCollectionViewController!

    public init() {
        rootCollectionViewController = BlahBlahCustomCollectionViewController()
        super.init(rootViewController: rootCollectionViewController)
    }

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nil, bundle:nil)

        rootCollectionViewController = BlahBlahCustomCollectionViewController()
        setViewControllers([rootCollectionViewController], animated: false)
    }

    required public init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    //No code other than above
}
public class BlahBlahCustomCollectionViewController {
    //...

    public init() {
        let flowLayout = UICollectionViewFlowLayout()
        flowLayout.minimumInteritemSpacing = 1
        flowLayout.minimumLineSpacing = 1
        flowLayout.itemSize = CGSize(width: 75, height: 75)
        super.init(collectionViewLayout: flowLayout)

        collectionView!.backgroundColor = UIColor.whiteColor()
        title = ""
    }

    required public init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    //...
}
我用来演示的
BlahBlahCustomNavigationController
代码只是
presentViewController(MultiSelectImagePickerController(),动画:true,完成:nil)


我已经查找了示例代码和所有这些东西,但是示例代码连接它们的
UINavigationController
s和
UICollectionViewController
s的方式与我的相同,但是为什么我的视图控制器没有出现?你能指出哪里出了问题吗?谢谢P

您是否设置了初始视图控制器?@Wingzero我正在屏幕上的视图控制器中演示自定义UINavigationController。由于问题似乎出在演示中,您需要显示演示的方法,您不这样认为吗?@rdelmar好的,谢谢。该方法只是一个简单的
presentViewController(MultiSelectImagePickerController(),动画:true,完成:nil)