我有五个UIButton
,我需要将框架设置为UIButton
适合不同尺寸的框架。但是从下面的代码中,它的加载很好,但问题是加载堆栈后,当我移动到to 或 to时,它应该根据我设置的大小进行更改..但这没有发生......它已经重叠之前的按钮已经创建..我需要进行哪些更改,以便在更改视图时..按钮应该正确..不应该重叠。Landscape
portrait
viewDidLoad
Landscape
portrait
portrait
Landscape
viewdidload
-(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];
}