Objective c 单击tableView中的行后在superview中添加新视图

Objective c 单击tableView中的行后在superview中添加新视图,objective-c,ios,uitableview,Objective C,Ios,Uitableview,我的didSelectRowAtIndexPath: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [UIView beginAnimations:@"View Flip" context:nil]; [UIView setAnimationDuration:1.25]; [UIView setAnimationCurve:UIViewAnimati

我的didSelectRowAtIndexPath:

 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 [UIView beginAnimations:@"View Flip" context:nil];
 [UIView setAnimationDuration:1.25];
 [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

 [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
 [self.view removeFromSuperview];
 [self.view.superview addSubview:commentsViewController.view];

 [UIView commitAnimations]; }

我将CommentsViewController类添加到root.h文件中。commentsViewController是此类的变量。单击“我的超级视图”后将消失,但新视图不会插入。我的问题是什么?

您正在从superview调用self.view remove,之后可能没有对super view的引用,因为您从superview中删除了它,您必须先调用superview addSubView,然后再调用self.view remove from superview

实际上我不需要从super view中删除某些内容,这是我的错误。问题在于将新视图插入superview中。