2013-12-05 6 views
1

У меня есть UIScrollView с некоторыми элементами внутри. Один из них - UITableView. Мне нужно скрыть это представление таблицы, перезагрузить его содержимое и показать снова, но когда я делаю [self.tableView reloadData];, таблица никогда не появляется, она все равно скрывается.UITableView исчез, когда 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}> 

I изменить fr AME вручную во втором блоке завершения добавления этого:

CGRect frame = self.tableMotives.frame; 
frame.origin.y = 1000; 
frame.size.height = 800; 
[self.tableMotives setFrame:frame]; 

И стол появился ...

Отредактировано:

Спасибо, ребята, прежде, чем пытались ваши предложения, я обнаружил, что, когда reloadData называется tableView переустанавливается в исходное положение StoryBoard. Кажется, что потерял свою рамку и получил рамку, указанную в storyboard. Кто-нибудь это понимает?

+0

Пробовали ли вы установить альфа в 1.0f вместо 1? – scollaco

+0

привет, да, я пробовал. Только не показывать таблицу, когда я звоню reloadData –

+0

Вы говорите, что если вы выберете вызов reloadData, он будет работать так, как ожидалось? Вы уверены, что представление таблицы действительно скрыто, а не просто пустое? –

ответ

0

попробовать скрытое свойство Tableview

[self.tableMotives setHidden:YES]; 

и набор Недоступен для не после перезагрузки

[self.tableMotives setHidden:NO]; 
+0

Спасибо, но не работает :( –

0

Попробуйте

- (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) { 

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

Спасибо Adithya, тот же результат :(Я отредактировал вопрос. –

0

Попробуйте это. Это сработало для меня.

Надеется, что это помогает ... :)

- (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]; 
    }]; 
} 

- (void)showTableMotives{ 
    NSLog(@"Showing table and reloading data"); 

    // Showing tableView 
    [UIView animateWithDuration:1.5 animations:^{ 
     self.tableMotives.alpha = 1; 
     self.textComments.alpha = 1; 
    } completion:^(BOOL finished) { 
    }]; 
} 

-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //Some other code if needed 
    if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){ 
     //end of loading 
     [self showTableMotives]; 
    } 
} 


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 24; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath  *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"]; 
    if (!cell) { 
     cell = [[UITableViewCell alloc] init]; 
    } 
    cell.textLabel.text = [NSString stringWithFormat:@"Row %d", indexPath.row]; 

    return cell; 
} 
+0

Спасибо amanhuipg, но все еще не работает. Думаю, что у меня есть ключ Я обновил свой вопрос. –

Смежные вопросы