当我将iPad方向属性设置为横向时,我的iPad应用程序处于纵向状态,其视图边界不会改变,只需768 x 1024
尺寸。
这里我的问题是当我改变方向时视图的界限不会改变。
这是我的代码:
if(self.hidden || hiding || !view.superview) {
UIWindow *viewWindow=[[UIWindow alloc]init];
if([self isPad]){
viewWindow = forView.window;
}
[[NSNotificationCenter defaultCenter] postNotificationName:CustomKeyboardWillShowNotification object:self];
// remove from old view and add to new view (if necessary)
if(view.superview && (view.superview != viewWindow)) {
[view removeFromSuperview];
}
if(!view.superview) {
CGFloat x;
if([self isPad]){
[view setFrame:CGRectMake(0, 0, 1024, 198)];
NSLog(@"view frame=%@",view);
x = view.bounds.size.width /2;
NSLog(@"x=%f",x);
}else
{
x = view.bounds.size.width / 2;
}
//CGFloat y = viewWindow.frame.size.height + (view.frame.size.height / 2);
CGFloat y;
if([self isPad]){
y = viewWindow.frame.size.height/1.3 + (view.frame.size.height);
NSLog(@"y=%f",y);
}else{
y = viewWindow.frame.size.height + (view.frame.size.height / 2);
}
//self.hiddenCenter = CGPointMake(x, y);
self.hiddenCenter = CGPointMake(x, y);
view.center = hiddenCenter;