ios - 从容器 View 中呈现 View Controller

标签 ios objective-c uiviewcontroller presentviewcontroller

我构建了一个 UIViewController,其中包含一个容器 View ,该 View 嵌入了另一个 UIViewController(我将其称为 subViewController)。 我希望 subViewController 在其容器 View Canvas 中呈现它自己的另一个实例(不是针对所有屏幕)。

我尝试使用 prepareForSegue 方法 用这个方法

-(void)showFurtherReadingDetails
{
    [self performSegueWithIdentifier:@"ShowArticleDetails" sender:self];
}

注意:showFurtherReadingDetails 方法是 subVC over 的委托(delegate)方法,在 supperVC 中初始化。 但我遇到了这个问题:

'NSInternalInconsistencyException', reason: 'There are unexpected subviews in the container view. Perhaps the embed segue has already fired once or a subview was added programmatically?'.

请看附图enter image description here

最佳答案

如果你的 UIViewController 没有嵌入 UINavigationController 那么你不能执行推送。

您需要做的是,将导航 Controller 嵌入到您的 subVC 中,然后从 subVC 推送新的 View Controller ,它将处于容器 View 中,并且不会占据全屏。

为方便起见,我附上了 Storyboard的屏幕截图,以便您更好地理解。希望对您有所帮助。

enter image description here

关于ios - 从容器 View 中呈现 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33318417/

相关文章:

ios - 如何在界面生成器上将 UITextView 作为 subview 添加到 UIImageView 中?

iOS 应用程序在保留在后台时返回到 rootViewController

objective-c - NSString 和 int 连接

ios - 无法在模态 Controller View 前面添加 View

ios - 设备上的 Xcode 11 实时预览失败,但应用程序运行正常

objective-c - 查找 Mac OSX 序列号

ios - 使用 Cocoapods 和 AFNetworking 构建错误

ios - 滑入/滑出 subview Controller 在 Swift 的父 View Controller 上部分可见

ios - 如何在 iOS 上创建一个可工作的可中断 View Controller 转换?

ios - View Controller 获取重复实例化