ios - UITableView 在 reloadData 时消失了

标签 ios ipad uitableview animation frame

我有一个 UIScrollView里面有一些元素。其中之一是 UITableView .我需要隐藏此 TableView ,重新加载其内容并再次显示,但是当我制作 [self.tableView reloadData]; 时该表从未出现,它仍然隐藏。

- (void)hideTableMotivesAndReloadData
{
    NSLog(@"Hiding table and reloading data");

    // Hiding tableView
    [UIView animateWithDuration:0.5 animations:^{
        self.tableMotives.alpha = 0;
        self.textComments.alpha = 0;
    } completion:^(BOOL finished) {

        [self.tableMotives reloadData];

        [UIView animateWithDuration:1.5 delay:1.2 options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut
        animations:^{
            self.tableMotives.alpha = 1;
            self.textComments.alpha = 1;
        } completion:^(BOOL finished) {
            //
        }];

    }];
}

有什么建议么?谢谢!

已编辑:

我添加了 NSLog(self.tableMotives.description)之前和之后 reloadData调用,结果如下:

前:
<UITableView: 0x1529bc00; frame = (-1 789; 770 420); clipsToBounds = YES; hidden = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x14d73960>; layer = <CALayer: 0x14d9a5c0>; contentOffset: {0, 0}>

后:
<UITableView: 0x1529bc00; frame = (-1 344; 770 81); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x14d73960>; layer = <CALayer: 0x14d9a5c0>; contentOffset: {0, 0}>

我在第二个完成 block 中手动更改了框架,添加了这个:
CGRect frame = self.tableMotives.frame;
frame.origin.y = 1000;
frame.size.height = 800;
[self.tableMotives setFrame:frame];

table 出现了……

已编辑:

谢谢大家,在尝试您的建议之前,我发现 reloadData被称为 tableView被重命名为 StoryBoard原来的位置。似乎丢失了他的框架并获得了 storyboard 中指定的框架.有人明白吗?

最佳答案

尝试 tableview 的隐藏属性

[self.tableMotives setHidden:YES];

并在重新加载后将 hidden 设置为 no
[self.tableMotives setHidden:NO];

关于ios - UITableView 在 reloadData 时消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20400807/

相关文章:

iphone - 按日期对提取请求进行排序

iphone - iOS 在 LoginView 上登录后切换到另一个 ViewController/View

ios - 同一个 UIViewController 中的两个 UITableView

ios - 更改 UIViewTableCell 样式不起作用

ios - leadingSwipeActions 与自定义手势冲突

ios - 将对象保持在屏幕内。 swift SpriteKit

ios - 我们如何将我们在 dribbble 上看到的精彩动画实现到 ios 应用程序?

ios - 为什么 AdMob 测试广告出现在我的应用上,但实际广告不再显示?

ios - 关于日期和时间设置更改的通知

iphone - 适用于网站的 iOS native 客户端应用程序