[英]Add UIViewController inside a Subview of custom UITableViewCell
I have a custom UITableViewCell with XIB. 我有一个带有XIB的自定义UITableViewCell。 It has a webview and UIView named slideShow.
它具有一个webview和一个名为slideShow的UIView。 I just want to add a custom uiviewcontroller inside slideShow UIView component.
我只想在slideShow UIView组件内添加一个自定义uiviewcontroller。 While doing that, when i addChildViewController, it is crashing.
这样做时,当我addChildViewController时,它崩溃了。
I'm able to add this ViewController as a subview in self.view. 我可以将此ViewController添加为self.view中的子视图。 But not able to add in a view inside custom tableviewcell
但是无法在自定义tableviewcell内添加视图
Please help.. 请帮忙..
self.homePageCell = (SSHomePageCell *)[tableView dequeueReusableCellWithIdentifier:@"SSHomePageCell"];
if (self.homePageCell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SSHomePageCell" owner:self options:nil];
self.homePageCell = [nib objectAtIndex:0];
}
self.imageShow = (ImageSlideShowViewController *) [storyboard instantiateViewControllerWithIdentifier:@"ImageSlideShow"];
self.imageShow.view.frame = CGRectMake(0, 0, self.homePageCell.imageSlideShowContainerView.frame.size.width, self.homePageCell.imageSlideShowContainerView.frame.size.height);
self.imageShow.title = self.title;
[self addChildViewController:self.imageShow];
[self.homePageCell.imageSlideShowContainerView addSubview:self.imageShow.view];
[self.imageShow didMoveToParentViewController:self];
return self.homePageCell;
First You set nib of UIView In CellForRow Like that 首先,像这样在CellForRow中设置UIView的笔尖
UIView *View = [[[NSBundle mainBundle] loadNibNamed:"UIView Name" owner:self options:nil] objectAtIndex:0];
View.frame = CGRectMake(0, 0,self.view.frame.size.width,self.view.frame.size.height);
[self.view addSubview:View];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.