开发者

Trying to remove Super ViewController but stuck in View?

I have 3 ViewCont开发者_如何转开发rollers 1.Main 2.Gallery 3.Text. What my problem is that i have the GalleryViewController using an External UIView with the name GalleryItemView. So once the view controller calls this inside the UIView i have a button that changes the subview so what i do is use the [super addSubView:newView]; eveything works out great but when i return to the GalleryViewController my app crashes so im guessing im doing this wrong. also what i notice is that once i change Views from pressing the button inside the GalleryViewController takes me to the menu and when i do a swipe gesture it scrolls horizontal and i do have a scrollview in the GalleryViewController Class so maybe what im doing is adding a subview to the ScrollView anyone know how i can fix this?


For starters:

[super addSubView:newView];

is pretty much incorrect.

Adding a view to a viewcontroller, you want to do

[self.view addSubview:galleryItemView];  
[self.view bringSubviewToFront:galleryItemView]; 

If you believe you have added it properly, you could do the following to verify it:

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

Please post the crash if you still have problems.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜