我为我的应用程序和界面构建器中的所有视图控制器创建了一个IBOutlet,我将插座连接到适当的控制器.每个控制器也加载适当的XIB,所以这都不是问题所在.问题是以下更改视图代码.
这是我的代码:
-(voID)changeVIEws { CGRect frame = self.vIEw.frame; frame.origin.x = CGRectGetMaxX(frame); theVIEw4.vIEw.frame = frame; [self.vIEw addSubvIEw:theVIEw4.vIEw]; [self addChildVIEwController:theVIEw4]; [self TransitionFromVIEwController:theVIEw1 toVIEwController:theVIEw4 duration:1 options:UIVIEwAnimationoptionTransitionNone animations: ^{ CGRect frame = self.vIEw.frame; theVIEw4.vIEw.frame = frame; frame.origin.x -= frame.size.wIDth; self.vIEw.frame = frame; } completion:completion:nil];
这是控制台崩溃:
*** Terminating app due to uncaught exception 'NSinvalidargumentexception',reason: 'Children vIEw controllers <MyGameVIEwController: 0x1dd25210> and <Settings: 0x1dd249d0> must have a common parent vIEw controller when calling -[UIVIEwController TransitionFromVIEwController:toVIEwController:duration:options:animations:completion:]'
有谁知道如何解决这一问题?
谢谢!
解决方法 你可以用这个:When you use
addChildVIEwController:
to add the child vIEw
controller to the surrounding one. You also have to notify the child
controller bydIDMovetoVIEwController:
that it has been put into
another controller. You can also useTransitionFromVIEwController:toVIEwController:
to exchange one vIEw
controller for another,optionally giving an animation.
这取自here(我建议你完全阅读已接受的答案).
长话短说,您还需要告知它确实进入了父视图控制器.
总结以上是内存溢出为你收集整理的ios – 子视图控制器必须有一个共同的父视图控制器?全部内容,希望文章能够帮你解决ios – 子视图控制器必须有一个共同的父视图控制器?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)