Iphone: popup button in UIWebView

I want to put popup buttons like email in a UIWebView. In my application, I created an ebook

in webView now when I click (long press) on the index page link, it will create a popup

with open and copied buttons like shwon, as shown below:             enter image description here

Like I want to add another button, such as email and print. How to create another button in a popup in WebView? Thanks in advance!

+5
source share
2 answers

, , UIMenuController. [UIMenuController sharedMenuController], . UIMenuItems .

UIMenuItem* myBtn1 = [[[UIMenuItem alloc] initWithTitle: @"Button 1" action:@selector( onButton1: )] autorelease];
UIMenuItem* myBtn2 = [[[UIMenuItem alloc] initWithTitle: @"Button 2" action:@selector( onButton2: )] autorelease];
UIMenuController* mc = [UIMenuController sharedMenuController];
mc.menuItems = [NSArray arrayWithObjects: myBtn1, myBtn2, nil];

- (void) onButton1: (UIMenuController*) sender
{
}

- (void) onButton2: (UIMenuController*) sender
{
}

. apple Doc.

Edit

Long Gesture

UILongPressGestureRecognizer* gr = [[[UILongPressGestureRecognizer alloc] initWithTarget: self action: @selector( onShowMenu: ) ] autorelease];
   [_myview addGestureRecognizer: gr];



- (void) onShowMenu: (UIGestureRecognizer*) sender
{
    [sender.view becomeFirstResponder];

    UIMenuController* mc = [UIMenuController sharedMenuController];

    CGRect bounds = sender.view.bounds;

    [mc setTargetRect: sender.view.frame inView: sender.view.superview];
    [mc setMenuVisible: YES animated: YES];
}
+5

, .xib view .

UIPopover.. .

, popover , , 1-3, , popOver. , webView i.e

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

,

+1

All Articles