Under xcode7.2,ios9.2 Environment
Try to add longpress gestures inside the Collectionviewcell to show the Uimenucontroller.
@implementation Collectionviewcell//inherits from Uicollectionviewcell uilongpressgesturerecognizer *longpress = [[UILongPress
Gesturerecognizer Alloc] initwithtarget:self action: @selector (longpress:)];
Longpress.minimumpressduration = 1;
[Self addgesturerecognizer:longpress];//add long press gesture//implementation long by Method-(void) Longpress: (Uilongpressgesturerecognizer *) gesture { Switch (gesture.state) {case Uigesturerecognizerstatebegan: {[Self Becomefirstresponder];<span style= Color:rgb (255, 0, 0); " >//must have!
</span> Uimenucontroller *menu = [Uimenucontroller Sharedmenucontroller];
UIMenuItem *item1 = [[UIMenuItem alloc] initwithtitle:@ "Save" Action: @selector (Savepic)];
Menu.menuitems = [Nsarray arraywithobject:item1];
[Menu SetTargetRect:self.scView.frame InView:self.scView.superview];
[Menu Setmenuvisible:yes Animated:yes];
} break;
Default:break; } <span style= "Color:rgb (0, 128, 0);" >//must be implemented. Note Not-(BOOL) Becomefirstresponder method </span>-(BOOL) CANBECOMEFIRSTRESPONDEr {return YES}
By implementing the above code, you can display Uimenucontroller when the cell is long pressed. But one of the problems is that when I slide CollectionView, the menu doesn't hide the first time.
So you can do it inside the way you want the menu to hide. Implement the following code.
Uimenucontroller *menu = [Uimenucontroller Sharedmenucontroller];
[Menu Setmenuvisible:no Animated:no];
The above is uimenucontroller within the cell can not show the solution, I hope that the learning of everyone help, but also hope that we support the cloud habitat community.