저는 5 개의 UIButton
을 가지고 있으며, Landscape
과 portrait
크기가 서로 다를 수 있도록 UIButton
프레임을 설정해야합니다. 하지만 아래의 코드 viewDidLoad
로드가 잘되지만 문제는 스택을로드 한 후 에서 portrait
또는 portrait
에서 Landscape
으로 이동하면 설정 한 viewdidload
크기에 따라 변경해야합니다. 일어나지 않는 ... 이전 버튼이 이미 생성 된 것처럼 오버랩되었습니다 .... 어떤 변화가 필요합니까? 뷰를 변경하면 .. 버튼이 제대로 나타나야합니다. 겹치지 않아야합니다.LandScape/Portrait 크기가 다릅니다. iOS
-(void)viewDidLoad{
int Height = 200;
int Yposition = 20;
for (int k=0; k<5; k++)
{
if ([UIApplication sharedApplication].statusBarOrientation== UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
UIButton *loPlayButton=[UIButton buttonWithType:UIButtonTypeCustom];
[loPlayButton addTarget:self action:@selector(PlayButtonAction:) forControlEvents:UIControlEventTouchUpInside];
// loPlayButton.tag = 100+k;
NSLog(@"tag is %i",loPlayButton.tag);
loPlayButton.alpha = 1.0;
UIImage *image=[UIImage imageNamed:@"vid.png"];
[loPlayButton setBackgroundImage:image forState:UIControlStateNormal];
loPlayButton.frame=CGRectMake(520, Yposition +(k*Height +170), image.size.width, 30);
// loPlayButton.tag=3;
[mScrollView_por addSubview:loPlayButton];
[mPlayButtonsArray addObject:loPlayButton];
}
if ([UIDevice currentDevice].orientation==UIInterfaceOrientationPortrait || [UIDevice currentDevice].orientation == UIInterfaceOrientationPortraitUpsideDown) {
UIButton *loPlayButton=[UIButton buttonWithType:UIButtonTypeCustom];
[loPlayButton addTarget:self action:@selector(PlayButtonAction:) forControlEvents:UIControlEventTouchUpInside];
// loPlayButton.tag = 100+k;
NSLog(@"tag is %i",loPlayButton.tag);
loPlayButton.alpha = 1.0;
UIImage *image=[UIImage imageNamed:@"vid.png"];
[loPlayButton setBackgroundImage:image forState:UIControlStateNormal];
loPlayButton.frame=CGRectMake(440, Yposition +(k*Height +170), image.size.width, 30);
// loPlayButton.tag=3;
[mScrollView_por addSubview:loPlayButton];
[mPlayButtonsArray addObject:loPlayButton];
}}}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self viewDidLoad];
}
없이 이런 일이되지 ... – user2102546