标签: uimenucontroller

在自定义视图/ uiview子类上实现iphone的复制/粘贴控件

我承认在SO上已经存在这些问题,但它缺乏实现细节,工作答案,我想更具体,所以我认为一个新问题是有道理的.显然,让我知道如果我错了,我们可以尝试在那里重新启动线程.

基本上,我想在用户按住标签时将UILabel中的文本复制到粘贴板.老实说,不难做到.但是,我认为提供视觉反馈的最佳方法是使用"复制"菜单选项提示用户UIMenuController.

根据"iPhone应用程序编程指南"的"事件处理"部分,特别是" 复制","剪切"和"粘贴操作"部分,应该可以从自定义视图中提供复制,剪切和/或粘贴操作.

因此,我已经按照指南所描述的以下实现对UILabel进行了分类,但UIMenuController将不会显示.指南中没有任何迹象表明还有其他任何操作要求,并且NSLog语句会打印到控制台,指示当我按住标签时正在执行选择器:

//
//  CopyLabel.m
//  HoldEm
//
//  Created by Billy Gray on 1/20/10.
//  Copyright 2010 Zetetic LLC. All rights reserved.
//

#import "CopyLabel.h"

@implementation CopyLabel

- (void)showCopyMenu {
    NSLog(@"I'm tryin' Ringo, I'm tryin' reeeeal hard.");
    // bring up editing menu.
    UIMenuController *theMenu = [UIMenuController sharedMenuController];
    // do i even need to show a selection? There's really no point for my implementation...
    // doing it any way to see if …
Run Code Online (Sandbox Code Playgroud)

iphone copy-paste uimenucontroller

7
推荐指数
1
解决办法
8320
查看次数

显示UIMenuController丢失键盘

我正在创建一个类似于手机上的消息应用程序的iPhone应用程序.我只是设置了通过UIMenuController复制消息的能力,但是如果键盘正在显示并且有人试图复制消息,键盘就会消失(大概是因为我[cell becomeFirstResponder];在哪里cell复制了消息单元).

有没有办法显示复制邮件而不会丢失键盘?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath {

    //...other cell setup stuff...

    UILongPressGestureRecognizer *longPressGesture =
    [[UILongPressGestureRecognizer alloc]
      initWithTarget:self action:@selector(showCopyDialog:)];
    [cell addGestureRecognizer:longPressGesture];

    return cell;
}

- (void)showCopyDialog:(UILongPressGestureRecognizer *)gesture
{
    if (gesture.state == UIGestureRecognizerStateBegan)
    {
        ConvoMessageCell *cell = (ConvoMessageCell *)[gesture view];
        NSIndexPath *indexPath = [self.tblConvo indexPathForCell:cell];

        UIMenuController *theMenu = [UIMenuController sharedMenuController];
        [cell becomeFirstResponder];
        [theMenu setTargetRect:CGRectMake(menuX, menuY, 100, 100) inView:cell];
        [theMenu setMenuVisible:YES animated:YES];        
    }
}
Run Code Online (Sandbox Code Playgroud)

iphone copy first-responder uimenucontroller

7
推荐指数
2
解决办法
2544
查看次数

IOS UIMenuController UIMenuItem,如何确定用通用选择器方法选择的项目

通过以下设置

....
MyUIMenuItem *someAction  = [[MyUIMenuItem alloc]initWithTitle : @"Something"  action : @selector(menuItemSelected:)];
MyUIMenuItem *someAction2 = [[MyUIMenuItem alloc]initWithTitle : @"Something2" action : @selector(menuItemSelected:)];
....

- (IBAction) menuItemSelected : (id) sender
{
    UIMenuController *mmi = (UIMenuController*) sender;
}
Run Code Online (Sandbox Code Playgroud)

如何确定选择了哪个菜单项.

并且不要说你需要有两种方法......提前谢谢.

uimenucontroller ios

7
推荐指数
1
解决办法
5674
查看次数

自定义UIMenuController

嗨,我想在IPhone SDK3.x中创建自定义的气泡菜单,如剪切/复制/粘贴菜单.我知道它是UIMenuController,但它只提供标准的剪切/复制/过去菜单.任何人都知道如何制作类似这样的气泡菜单.任何示例和代码供参考?

iphone uimenucontroller

6
推荐指数
2
解决办法
2万
查看次数

iOS:如何从UIMenuController获取所选的UIMenuItem

我试图用来UIMenuCnotroller显示动态生成的项目列表,它们共享相同的操作方法,因此我需要知道在单一操作方法中选择了哪个项目.

但是,在动作方法中- (void)menuItemAction:(id)sender;,发送者实际上是UIMenuController对象,我没有找到任何方法UIMenuController可以告诉我选择了哪个menuitem.

我能想到的一个解决方案是为不同的项动态生成不同的动作选择器,并做一些技巧 forwardInvocation

但是有更简单的方法吗?

menu uimenucontroller ios

6
推荐指数
1
解决办法
3482
查看次数

从TableView中的UIMenuController中删除默认剪切,复制和粘贴

我正在尝试从UIMenuController中删除默认菜单项.我找到了UIWebview或UITextView的这篇文章:

如何从iOS中的UIMenuController中删除默认的UIMenuItem?

我正在尝试为新的iOS 5方法执行此操作,您可以在表格选择上显示菜单项.所以我的类是UIViewController的子类,里面有一个UITableView.我不确定如何或如果删除默认项目是可能的.谢谢!

iphone uimenucontroller

6
推荐指数
1
解决办法
1761
查看次数

UIMenuController隐藏了键盘

我目前有一个用于聊天的应用程序.我使用UItextField作为输入框和气泡来显示消息,有些东西就像系统短信.我想在消息气泡(标签)上启用复制粘贴.问题是,当我想显示UIMenuController时,我需要复制的标签需要成为第一响应者.如果当前显示键盘,当标签成为第一响应者时,文本字段将失去焦点,因此键盘将自动隐藏.这导致UI滚动并感觉不好.无论如何,即使我需要显示菜单,我仍然可以保持键盘显示?

在此输入图像描述

在此输入图像描述

iphone uimenucontroller iphone-softkeyboard

6
推荐指数
2
解决办法
3117
查看次数

UIMenuController与自定义项目不使用UICollectionview

我在长按UICollectionViewCell时添加了自定义菜单控制器

    [self becomeFirstResponder];
    UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Custom Action"
                                                      action:@selector(customAction:)];
    [[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:menuItem]];
    [[UIMenuController sharedMenuController] setTargetRect: self.frame inView:self.superview];
    [[UIMenuController sharedMenuController] setMenuVisible:YES animated: YES];
Run Code Online (Sandbox Code Playgroud)

canBecomeFirstResponder也被调用

- (BOOL)canBecomeFirstResponder {
    // NOTE: This menu item will not show if this is not YES!
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

//未调用此方法

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
    NSLog(@"canPerformAction");
    // The selector(s) should match your UIMenuItem selector
    if (action == @selector(customAction:)) {
        return YES;
    }
    return NO;
}
Run Code Online (Sandbox Code Playgroud)

我也实现了这些方法

- (BOOL)collectionView:(UICollectionView *)collectionView
      canPerformAction:(SEL)action
    forItemAtIndexPath:(NSIndexPath *)indexPath
            withSender:(id)sender {


    if([NSStringFromSelector(action) …
Run Code Online (Sandbox Code Playgroud)

objective-c uimenucontroller uiresponder uicollectionview

6
推荐指数
3
解决办法
1万
查看次数

UIMenuController sharedMenuController - 用于uicollectionview的自定义menuitem不显示在ios 7中

我正在使用a UIMenuItemUICollectionView单元长按中执行自定义操作.这与iOS 6完美配合,但现在我将我的应用程序转换为iOS 7和Xcode 5,但它无法正常工作.自定义项目未显示.

UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Unfavorite"
                                                  action:@selector(unFavorite:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:menuItem]];
[UIMenuController sharedMenuController].menuVisible = YES;

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender;
{
    //do not show default itens like copy, paste....
    [self becomeFirstResponder];
    return NO;
}


- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// The selector(s) should match your UIMenuItem selector
    if (action == @selector(unFavorite:)) {
         return YES;
    }
    return NO;
}

- (void)collectionView:(UICollectionView *)collectionView
     performAction:(SEL)action
forItemAtIndexPath:(NSIndexPath *)indexPath
        withSender:(id)sender {

}

 - (BOOL)collectionView:(UICollectionView *)collectionView
 shouldShowMenuForItemAtIndexPath:(NSIndexPath …
Run Code Online (Sandbox Code Playgroud)

objective-c uimenucontroller uicollectionview ios7

6
推荐指数
1
解决办法
9047
查看次数

Second UIMenuController not Hiding

Tapping the cursor in a UITextView brings up a UIMenuController. Tapping Select causes the relevant text to be selected and another UIMenuController with new options to be displayed. Tapping anywhere else in the text view causes the "second" UIMenuController to hide.

系统行为示例

I have a custom UIMenuItem that, when tapped, selects the current line of text in a UITextView and then displays the UIMenuController again for subsequent actions, however the "second" UIMenuController does not hide when tapping anywhere else in the …

objective-c uikit uimenucontroller ios

6
推荐指数
1
解决办法
166
查看次数