reloadData in a UITableView when deviceOrientation change

I'm working with a UITableView, with UITableViewCell. Мое приложение поддерживает альбомную ориентацию, поэтому я создал 2 UITableViewCell: один для portraid и один для ландшафта.

В моем методе cellForRowAtIndexPath это мой код

static NSString *CellIdentifier;
static NSString *NibNamed;

UIDeviceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;

if (deviceOrientation != UIDeviceOrientationLandscapeLeft &&
    deviceOrientation != UIDeviceOrientationLandscapeRight)
{
    CellIdentifier= @"Cell1";
    NibNamed = @"cell_news";
}
else
{
    CellIdentifier= @"Cell2";
    NibNamed = @"cell_news_landscape";
}

[[NSBundle mainBundle] loadNibNamed:NibNamed owner:self options:NULL];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


if (cell == nil)
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:NibNamed owner:self options:nil];
    cell = [nib objectAtIndex:0];
}
///here i add title, description, ecc... in my UITableViewCell

Затем в shouldAutorotateToInterfaceOrientation я написал следующее:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
[my_table reloadData];
return YES;
}

Где находится проблема? Если я запускаю приложение в портретной ориентации, когда я поворачиваю устройство в первый раз, ничего не происходит (а UITableCellView - это portrait_table_cell). Когда я поворачиваю устройство во второй раз (и я в портретной ориентации или в перевернутом положении), я вижу landscape_table_cell (и, конечно, я не вижу весь текст, потому что он выходит за пределы экрана). Итак .. кроме первого раза, когда я поворачиваю устройство, я вижу неправильный table_cell_view !!

Знаете почему? Thanks!

5
задан JAA 14 April 2011 в 14:37
поделиться