Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get CGRect values x,y,width,height after view is being autoresized?

I want x,y,widht,height values of view when it is autoresized automatically when orientation of ipad changes. How can i get that?

like image 827
sam Avatar asked Mar 12 '12 10:03

sam


2 Answers

After the view has rotated you should be able to get the new dimensions of the view.

- (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);
}
like image 52
Peter Kelly Avatar answered Sep 28 '22 07:09

Peter Kelly


try this

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
   float x = yourView.bounds.origin.x;
   float y = yourView.bounds.origin.y; 

   float width = yourView.bounds.size.width;
   float height = yourView.bounds.size.height; 

   NSLog(@"x=%f,y=%f,w=%f,h=%f",x,y,width,height);
}
like image 38
Sanket Pandya Avatar answered Sep 28 '22 08:09

Sanket Pandya