我有五个UIButton
,我需要设置UIButton
的框架,使其应该为Landscape
和portrait
不同的大小。 但是从下面的代码viewDidLoad
它的加载不错,但问题是,加载堆栈后当我移动到Landscape
到portrait
或portrait
到Landscape
就应该按照我所设置..但是这是viewdidload
大小是变化没有发生......它已经重叠,因为以前的Button已经创建了....我需要做什么更改,以便在更改视图时..button应该正常显示..不应该重叠。LandScape /肖像大小不同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 2013-02-27 13:08:20