iphone - how to change the arrow direction of UIMenuController just before shown in an UIWebView -
i trying change arrow direction when appears not block top bar set application. here code used change direction:
uimenucontroller *menucontroller = [uimenucontroller sharedmenucontroller]; [menucontroller setarrowdirection:uimenucontrollerarrowup];
and here result, say, pretty stressful:
it appears same issue on iphone well.
can this? thanks
after days of researching, find way change arrow direction of menu controller in webview. first, please in view controller's viewdidload
method.
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(menucontrollerwillshow:) name:uimenucontrollerwillshowmenunotification object:nil]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(menucontrollerwillhide:) name:uimenucontrollerwillhidemenunotification object:nil];
then, add these 2 functions, arrow direction pointing up, in case menubar appear below text. (same way, can change uimenucontrollerarrowup;
other direction if want menubar appear in other position)
-(void)menucontrollerwillshow:(nsnotification *)notification{ //remove show notification prevent // "menucontrollerwillshow" function called multiple times [[nsnotificationcenter defaultcenter]removeobserver:self name:uimenucontrollerwillshowmenunotification object:nil]; //hide original menu view uimenucontroller* menucontroller = [uimenucontroller sharedmenucontroller]; cgpoint origin = menucontroller.menuframe.origin; cgsize size = menucontroller.menuframe.size; cgrect menuframe; menuframe.origin = origin; menuframe.size = size; [menucontroller setmenuvisible:no animated:no]; //modify target rect , show again prevent glitchy appearance menucontroller.arrowdirection = uimenucontrollerarrowup; [menucontroller settargetrect:menuframe inview:self.view]; [menucontroller setmenuvisible:yes animated:yes]; } -(void)menucontrollerwillhide:(nsnotification *)notification{ //re-register menucontrollerwillshow [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(menucontrollerwillshow:) name:uimenucontrollerwillshowmenunotification object:nil]; }
Comments
Post a Comment