Setting UIMenuController arrow direction not working

柔情痞子 提交于 2019-12-11 10:09:40

问题


I have a UIMenuController which I have added a few extra items to. I would like the menu to be BELOW the text that I select, so I tried:

[UIMenuController sharedMenuController].arrowDirection = UIMenuControllerArrowDown;

That seemed to do nothing, and everything I try, won't put the menu below the text.

How can I do that?


回答1:


According to the docs, arrowDirection sets the direction the arrow points; it has nothing to do with the location of the menu relative to its target area. It also looks like they don't give you any control over the positioning of the menu beyond setTargetRect:inView.

If you really want to put the menu below the text, you might be able to set a "fake" target area and change the arrow direction to point to the "real" area of interest.

However, there's probably a reason Apple does it this way. My guess? If you select some text with your finger, your hand is probably obscuring the part of the screen below the text... so it's not very helpful if the menu appears there. Going out of your way to break consistency with standard UI conventions isn't usually worth the effort.



来源:https://stackoverflow.com/questions/9798270/setting-uimenucontroller-arrow-direction-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!