0
我有一個XIB自定義的UITableViewCell。它有一個名爲slideShow的webview和UIView。我只想在slideShow UIView組件中添加一個自定義的uiviewcontroller。雖然這樣做,當我addChildViewController,它崩潰了。在UITableViewCell的子視圖中添加UIViewController
我可以將此ViewController作爲self.view中的子視圖添加。但是不能夠在內部自定義視圖添加tableviewcell
請幫助..
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;
使用uicontainer來看,它很容易在視圖中添加uiviewcontroller – NANNAV
請向我們展示您嘗試使其工作的代碼 – thxou
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; –