ios - How to prevent autorotate for UIAlertView? -


i'm working on application supporting portrait , landscape modes based on constraints. when uialertview popping up, autorotate feature causing weird effect. want avoid autorotation of uialertview only. please me

if declaring alertview in other class.. in case appdelegate

appdelegate.h

 @property bool alertshowing; 

appdelegate.m when call show alertview set bool alertview showing.

 uialertview *your_alertview = [[uialertview alloc] initwithtitle:title message:details delegate:self cancelbuttontitle:nil otherbuttontitles:@"okay", nil];  self.alertshowing = yes; //set bool property universally  [your_alertview show]; 

set bool no after dismiss of alertview

- (void)alertview:(uialertview *)alertview diddismisswithbuttonindex:(nsinteger)buttonindex   {    self.alertshowing = no;   } 

viewcontroller.m

then check bool before auto rotate.

-(bool)shouldautorotate {     bool rotate;    appdelegate *appdelegate = [[uiapplication sharedapplication] delegate];    if (appdelegate.alertshowing) {     if (appdelegate.alertshowing==yes) {         rotate = no;     }     else if(appdelegate.alertshowing == no)     {         rotate = yes;     }     }    else    {     rotate = yes;    }    return rotate; } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -