ios - How to redraw view layout on rotation -


i have .h file using thought project, #import file use #define vars layout views correctly.

this screensize.h file looks like.

#import <foundation/foundation.h>  #define screenwidth ((int) [uiscreen mainscreen].bounds.size.width) #define screenheight ((int) [uiscreen mainscreen].bounds.size.height)  @interface screensize : nsobject  @end 

i know when user browsing page , lays out correctly decide rotate how update screenwidth , screenheight correct values.. , update current view thats being rotated?

any appreciated.

this better implemented static methods, rather #defines:

+(cgfloat)screenwidth {     if(uiinterfaceorientationisportrait([uiapplication sharedapplication].statusbarorientation)){         return [uiscreen mainscreen].bounds.size.width;     }else{         [uiscreen mainscreen].bounds.size.height;     } }  +(cgfloat)screenheight {     if(uiinterfaceorientationisportrait([uiapplication sharedapplication].statusbarorientation)){         return [uiscreen mainscreen].bounds.size.height;     }else{         [uiscreen mainscreen].bounds.size.width;     } } 

to know when screen rotates, can subscribe uiapplicationwillchangestatusbarorientationnotification , uiapplicationdidchangestatusbarorientationnotification using nsnotificationcenter:

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(didrotate:) name:uiapplicationdidchangestatusbarorientationnotification object:nil]; 

and implement method handle notification:

-(void)didrotate:(nsnotification*)notification {     // layout views } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -