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
Post a Comment