2015-11-04 48 views
1

我開發了一個即時含義檢查器,就​​像UIMENU Button中的一個,它工作正常,但由於我使用alert方法來顯示含義,警告的出現並不是很好。任何一個可以告訴我怎麼去的,在UIMENU按鈕定義方法的外觀如何自定義ios中的定義函數

UIAlertView *av = [[UIAlertView alloc] initWithFrame:CGRectMake(0,0,300,200)];//[[UIAlertView alloc] initWithTitle:newstring message:nil delegate:nil cancelButtonTitle:@"ཕྱིར་འཐེན།" otherButtonTitles:nil]; 
    av.title = newstring; 
    av.layer.backgroundColor=(__bridge CGColorRef)([UIColor colorWithRed:22/255.0f green:113/225.0f blue:9/255.0f alpha:1.0f]); 
    av.message = nil; 
    av.delegate = nil ; 
    [av addButtonWithTitle:@"ཕྱིར་འཐེན།"]; 
    //[av addButtonWithTitle:@"OK"]; 
    UITextView *v = [[UITextView alloc] initWithFrame:CGRectMake(0,0,300,200)];  //av.bounds]; 
    v.text=newstring1; 
    [v setEditable:NO]; 
    v.font=[UIFont fontWithName:@"Monlam Uni OuChan2" size:19]; 
    [av setValue:v forKey:@"accessoryView"]; 
    v.backgroundColor = [UIColor yellowColor]; 
    [av show]; 

這是代碼,並且我得到了警報的看法是With the alert view of custom uimenu buttonWith the define function of the UIMENU button

+0

傢伙可以任何人有任何想法如何解決問題.... –

回答

0

我假設你是使用輕擊手勢來顯示菜單。 下面的代碼顯示爲100x100一UIMenu與標題爲「自定義操作」

- (void)handleTapGesture:(UITapGestureRecognizer *)tapGesture { 
    NSLog(@"tapGesture:"); 
// CGRect targetRectangle = self.tapView.frame; 
    CGRect targetRectangle = CGRectMake(100, 100, 100, 100); 
    [[UIMenuController sharedMenuController] setTargetRect:targetRectangle 
                inView:self.view]; 

    UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Custom Action" 
                action:@selector(customAction:)]; 

    [[UIMenuController sharedMenuController] 
    setMenuItems:@[menuItem]]; 
    [[UIMenuController sharedMenuController] 
    setMenuVisible:YES animated:YES]; 

} 

對於詳細的版本,看看here