TableViewCell과 함께 TableView를 사용하고 있습니다. 프로그래밍 방식으로 ImageView, Text 및 uibutton을 셀에 추가했습니다. 버튼의 프레임은 세로 및 가로 방향에 따라 다르게 설정됩니다. 그러나 장치를 세로에서 가로로 회전하면 하나가 아닌 두 개의 단추가 나타납니다.TableView에 표시된 2 개의 uibutton 장치 회전시 셀
가로 모드 버튼이 작동하지 않을 때 버튼을 제거하려고했습니다.
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