Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.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
Iphone 正在尝试删除超级ViewController,但卡在视图中?_Iphone_Objective C - Fatal编程技术网

Iphone 正在尝试删除超级ViewController,但卡在视图中?

Iphone 正在尝试删除超级ViewController,但卡在视图中?,iphone,objective-c,Iphone,Objective C,我有3个视图控制器1.Main 2.Gallery 3.Text。我的问题是GalleryViewController使用名为GalleryItemView的外部UIView。因此,一旦视图控制器在UIView中调用它,我就会有一个按钮来更改子视图,所以我要做的就是使用[super addSubView:newView];一切都很好,但当我回到GalleryViewController时,我的应用程序崩溃了,所以我猜我做错了。我还注意到,一旦我按GalleryViewController内的按钮

我有3个视图控制器1.Main 2.Gallery 3.Text。我的问题是GalleryViewController使用名为GalleryItemView的外部UIView。因此,一旦视图控制器在UIView中调用它,我就会有一个按钮来更改子视图,所以我要做的就是使用[super addSubView:newView];一切都很好,但当我回到GalleryViewController时,我的应用程序崩溃了,所以我猜我做错了。我还注意到,一旦我按GalleryViewController内的按钮更改视图,我就会进入菜单,当我做滑动动作时,它会水平滚动,我在GalleryViewController类中确实有一个滚动视图,所以我所做的可能是在滚动视图中添加一个子视图。有人知道我如何解决这个问题吗?

初学者:

[super addSubView:newView];
这是非常不正确的

要向viewcontroller添加视图,请执行以下操作:

[self.view addSubview:galleryItemView];  
[self.view bringSubviewToFront:galleryItemView]; 
如果您认为已正确添加,可以执行以下操作进行验证:

if ([galleryItemView.superview isKindOfClass:[UIScrollView class]]){
  NSLog(@"galleryItemView's parent is a scrollview"); 
}

如果您仍然有问题,请发布崩溃

你好,大卫,谢谢你的回答,我还没试过;但我到家后会的。我想在,我使用[super addSubView:newView]的地方做个笔记;在UIView本身上,因此这阻止我使用[self.view addSubview:galleryItemView];我收到一个编译器错误,说self.view不在并集中。更改视图的按钮位于UIView上