我在UIMENU Button中开发了一个即时意义检查器,它运行正常,但由于我使用了警报方法来显示含义,警报的出现并不好。任何人都告诉我如何获取UIMENU按钮中的define方法的外观
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];
答案 0 :(得分:0)
我假设您使用点击手势来显示菜单。 以下代码显示UIMenu为100x100,标题为"自定义操作"
- (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。