[英]Adding UITableViewController.view as subview behaving badly
我正在尝试为视图中的表视图添加动画,但是无法显示UITableView中的数据(下面的NAConversationViewController是UITableViewController的子类):
Post *post = [self.fetchedResultsController objectAtIndexPath:indexPath];
UIView *takeover = [[UIView alloc] initWithFrame:self.view.frame];
takeover.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.75];
NAConversationViewController *vc = [[NAConversationViewController alloc] initWithNibName:@"NAConversationViewController" bundle:nil];
vc.managedObjectContext = self.managedObjectContext;
vc.post = post;
vc.view.frame = CGRectMake(0, self.view.frame.size.height, 320, 320);
[takeover addSubview:vc.view];
[self.view addSubview:takeover];
[UIView animateWithDuration:0.2
animations: ^{
vc.view.frame = CGRectMake(0, 100, 320, 320);
}
completion:^(BOOL finished) {
if (finished) {
[vc.view setNeedsDisplay];
}
}];
我可以获取要显示的表数据的唯一方法是[vc.view setNeedsDisplay]; 但是当我在表格视图上滚动时,表格单元立即消失了。
我是否错误地调用了UITableView?
如果使用的是ARC,则可能正在发布NAConversationViewController实例,并且它也是视图。...尝试创建实例变量,以使视图控制器不会被释放。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.