如何在视图自动调整后获得CGRect值x,y,width,height?

sam*_*eet 5 iphone objective-c ipad ios

当ipad的方向改变时,我想要自动自动调整时的x,y,widht,高度值.我怎么能得到它?

Pet*_*lly 17

视图旋转后,您应该能够获得视图的新尺寸.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    CGRect myFrame = [self.view frame];
    NSLog(@"height = %f", myFrame.size.height);
    NSLog(@"width = %f", myFrame.size.width);
    NSLog(@"x = %f", myFrame.origin.x);
    NSLog(@"y = %f", myFrame.origin.y);
}
Run Code Online (Sandbox Code Playgroud)