没有显示 uitextview 的 uimenucontroller,通用应用程序 xcode 4

发布于 2024-11-19 07:05:39 字数 805 浏览 3 评论 0 原文

在模拟器上,我看到 UIMenucontroller 没有问题,但它不会在运行 iOs 4+ 的设备上进行测试。它是使用IB添加的标准uitextview。

我已将这些方法添加到作为委托的视图控制器中,但我认为它们不是必需的,因为我想要标准的菜单控制器、选择、复制等。更不用说它们没有被调用。

谢谢你的帮助

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

    NSLog(@"Can perform action called");

    BOOL answer = NO;

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

    return answer;
}

- (BOOL) canBecomeFirstResponder {
    NSLog(@"can become first called");
    return YES;
}

On the simulator I see the UIMenucontroller without a problem but it won't appear testing on device running iOs 4+ . It is a standard uitextview added using IB.

I have added these methods to the viewcontroller which is the delegate but I don't think they are necessary since I want the standard menucontroller, select, copy, etc. Not to mention they are not being called.

thanks for the help

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

    NSLog(@"Can perform action called");

    BOOL answer = NO;

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

    return answer;
}

- (BOOL) canBecomeFirstResponder {
    NSLog(@"can become first called");
    return YES;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗酒趁年少 2024-11-26 07:05:39

您需要添加手势识别器,或覆盖touchesEnded:withEvent:方法,并显示菜单控制器:

//Assumes you assigned a CGRect for where the menu should appear to theRect
UIMenuController *mc = [UIMenuController sharedMenuController];
[mc setTargetRect:theRect inView:self];
[mc setMenuVisible:YES animated:YES];

您还应该覆盖方法 -复制、剪切、粘贴等。

You need to add a gesture recognizer, or override the touchesEnded:withEvent: method, and display the menu controller:

//Assumes you assigned a CGRect for where the menu should appear to theRect
UIMenuController *mc = [UIMenuController sharedMenuController];
[mc setTargetRect:theRect inView:self];
[mc setMenuVisible:YES animated:YES];

You also should override the methods -copy,-cut,-paste, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文