我创建了runtime image view
并向其添加了subviews
(仅like splash screen
概念)。现在我要为我的iPad处理所有4个旋转但它的方法是什么?
我的代码段:
UIView *mainScreen = [[[UIApplication sharedApplication]delegate]window];
UIView *windowBlocker = [[UIView alloc]initWithFrame:mainScreen.frame];
windowBlocker.tag = 999;
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(165, 200, 450, 480)];
imageView.layer.backgroundColor=[[UIColor colorWithRed:248/255 green:248/255 blue:248/255 alpha:0.5] CGColor];
imageView.alpha = 0.6;
imageView.layer.cornerRadius=10;
imageView.layer.masksToBounds = YES;
[windowBlocker addSubview:imageView];
以下方法为每次轮换设置每个子视图的坐标会很痛苦。不是吗? 如何在这里处理轮换。我还必须禁用自动布局以进行滚动。
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"Landscape left");
self.lblInfo.text = @"Landscape left";
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"Landscape right");
self.lblInfo.text = @"Landscape right";
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
NSLog(@"Portrait");
self.lblInfo.text = @"Portrait";
} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"Upside down");
self.lblInfo.text = @"Upside down";
}
}
请指导。 感谢
答案 0 :(得分:1)
UIView *mainScreen = [[[UIApplication sharedApplication]delegate]window];
UIView *windowBlocker = [[UIView alloc]initWithFrame:mainScreen.frame];
windowBlocker.tag = 999;
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(165, 200, 450, 480)];
imageView.layer.backgroundColor=[[UIColor colorWithRed:248/255 green:248/255 blue:248/255 alpha:0.5] CGColor];
imageView.alpha = 0.6;
imageView.layer.cornerRadius=10;
imageView.layer.masksToBounds = YES;
[windowBlocker addSubview:imageView];
[[[mainScreen subviews] objectAtIndex:0] addSubview:windowBlocker];