Implementing iphone's copy/paste controls on a custom view / uiview subclass

本小妞迷上赌 提交于 2019-11-30 05:20:35

I'll say upfront I don't have an aswer, but I did some poking around and found more out. I'm sure you've looked at this already: CopyPasteTile

That code does work on my simulator and goes like this:

CGRect drawRect = [self rectFromOrigin:currentSelection inset:TILE_INSET];
[self setNeedsDisplayInRect:drawRect];

UIMenuController *theMenu = [UIMenuController sharedMenuController];
[theMenu setTargetRect:drawRect inView:self];
[theMenu setMenuVisible:YES animated:YES];

There are a few differences here:

  • drawRect is calculated from a giant view tile and tap point calculations
  • setNeedsDisplayInRect is being called
  • self is a large screen sized view, you may need screen coords instead of local coords (you can probably get that from self.superview)

I'd try making these adjustments to match the example first and see what kind of progress it gets me.

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