开发者

no uimenucontroller with uitextview showing, universal app xcode 4

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(se开发者_开发百科lectAll:))
    {
        answer = YES;
    }

    return answer;
}

- (BOOL) canBecomeFirstResponder {
    NSLog(@"can become first called");
    return 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜