Я использую TableView с TableViewCell. Я программно добавил ImageView, Text и uibutton к ячейке. Рамка кнопки установлена для портретной и альбомной ориентации. Но когда устройство повернуто от портрета к пейзажу, отображаются две кнопки вместо одной.Два uibutton, показанные в TableView Cell, когда устройство повернуто
Я попытался удалить кнопку, когда в режиме ландшафтного режима ее не работает.
switch ([indexPath section])
{
case 0:
{
cell.imageView.image = [UIImage imageNamed:@"active.png"];
cell.textLabel.text = @"Application Name";
self.uninstallApplicationButton = [[UIButton alloc] init];
self.uninstallApplicationButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.uninstallApplicationButton setTitle:@"Install" forState: UIControlStateNormal];
[self.uninstallApplicationButton setBackgroundColor:[UIColor brownColor]];
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (device == UIUserInterfaceIdiomPhone)
{
if (UIInterfaceOrientationIsLandscape(orientation))
{
self.uninstallApplicationButton.frame = CGRectMake(490.0, 25.0, 65.0, 30.0);
}
else if(UIInterfaceOrientationIsPortrait(orientation))
{
self.uninstallApplicationButton.frame = CGRectMake(250.0, 25.0, 65.0, 30.0);
}
}
else if(device == UIUserInterfaceIdiomPad)
{
self.uninstallApplicationButton.frame = CGRectMake(600.0, 25.0, 150.0, 30.0);
}
}
[cell.contentView addSubview:uninstallApplicationButton];
break;
Пожалуйста, укажите соответствующий код. – Caleb
@Caleb Я добавил код. – Amon
Где вы пишете этот код? Возможно, он запускается более одного раза. – Desdenova