Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIMenuController自定义项不显示_Iphone_Objective C_User Interface_Uimenucontroller - Fatal编程技术网

Iphone UIMenuController自定义项不显示

Iphone UIMenuController自定义项不显示,iphone,objective-c,user-interface,uimenucontroller,Iphone,Objective C,User Interface,Uimenucontroller,我试图从UIImageView中显示自定义UIMenuController,它嵌入在UITextView中 我如何做到这一点 我得到一个菜单,显示剪切、复制、粘贴、选择、全选,如下图所示: 只有点击更多,我才能得到我想要的: 以下是我的一些代码: @interface UIImageView (Extended) - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (BOOL)canBecomeFirstRe

我试图从UIImageView中显示自定义UIMenuController,它嵌入在UITextView中

我如何做到这一点

我得到一个菜单,显示剪切、复制、粘贴、选择、全选,如下图所示:

只有点击更多,我才能得到我想要的:

以下是我的一些代码:

@interface UIImageView (Extended)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (BOOL)canBecomeFirstResponder;
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender;

@end

@implementation UIImageView (Extended)

- (BOOL)canBecomeFirstResponder {
    return YES;
}

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {

if (action == @selector(copy:) || action == @selector(paste:) || action == @selector(cut:) || action == @selector(delete:) || 
        action == @selector(select:) || action == @selector(selectAll:)) {
return YES; 
}

return NO;

}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

[self.nextResponder touchesBegan:touches withEvent:event];

}

@end

- (void)showMenuController {

UIMenuController *sharedController = [UIMenuController sharedMenuController];
UIMenuItem *moreOptionsItem = [[UIMenuItem alloc] initWithTitle:@"More options" action:@selector(imageMenuItemPressedMore:)];
UIMenuItem *cut = [[UIMenuItem alloc] initWithTitle:@"Cut" action:@selector(cutImageItemPressed:)];
UIMenuItem *copy_item = [[UIMenuItem alloc] initWithTitle:@"Copy" action:@selector(copyImagePressed:)];
UIMenuItem *paste = [[UIMenuItem alloc] initWithTitle:@"Paste" action:@selector(pasteImagePressed:)];
UIMenuItem *crop = [[UIMenuItem alloc] initWithTitle:@"Crop" action:@selector(cropImagePressed:)];

sharedController.menuItems = [NSArray arrayWithObjects:cut, copy_item, paste, crop, moreOptionsItem, nil];

[moreOptionsItem release];
[cut release];
[copy_item release];
[paste release];
[crop release];


[sharedController setTargetRect:CGRectMake(theView.frame.size.width/2, 0, 0, 0) inView:theView];
[sharedController setMenuVisible:YES animated:YES];

}
我做错了什么? 谢谢你的帮助