如何在popoverview中显示两个按钮-WEPOPOVER
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在popoverview中显示两个按钮-WEPOPOVER相关的知识,希望对你有一定的参考价值。
我想在popoverview中显示两个按钮。我正在使用WEPOPOVER,我可以显示一个btn。
但是我不确定如何显示两个按钮。
UIButton *editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[editBtn setTitle:@"EDIT ME" forState:UIControlStateNormal];
[editBtn setFrame:CGRectMake(250, 0, 100,40)];
[editBtn addTarget:self action:@selector() forControlEvents:UIControlEventTouchUpInside];
[editBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
editBtn.titleLabel.shadowOffset = CGSizeMake(0, -1);
editBtn.titleLabel.font = [UIFont boldSystemFontOfSize:20];
editBtn.backgroundColor = [UIColor blackColor];
UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[deleteBtn setTitle:@"Delete ME" forState:UIControlStateNormal];
[deleteBtn setFrame:CGRectMake(250, 0, 100,40)];
[deleteBtn addTarget:self action:@selector(doSubscription) forControlEvents:UIControlEventTouchUpInside];
[deleteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
deleteBtn.titleLabel.shadowOffset = CGSizeMake(0, -1);
deleteBtn.titleLabel.font = [UIFont boldSystemFontOfSize:20];
deleteBtn.backgroundColor = [UIColor blackColor];
// place inside a temporary view controller and add to popover
UIViewController *viewCon = [[UIViewController alloc] init];
viewCon.view = (UIView *)[NSArray arrayWithObjects:editBtn,deleteBtn, nil];
viewCon.contentSizeForViewInPopover = editBtn.frame.size; // Set the content size
navPopover = [[WEPopoverController alloc] initWithContentViewController:viewCon];
[navPopover presentPopoverFromRect:editButton.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown
animated:YES];
答案
您为两个按钮指定了相同的框架。因此它仅显示一个按钮。
[editBtn setFrame:CGRectMake(250, 0, 100,40)];
[deleteBtn setFrame:CGRectMake(250, 0, 100,40)];
以上是关于如何在popoverview中显示两个按钮-WEPOPOVER的主要内容,如果未能解决你的问题,请参考以下文章
在 Java 中使用 Selenium 与 wep 页面交互时遇到问题
如何从 swift 中的按钮选项中删除 uitableviewcell?
PopoverView 控制器中的问题 PreferredContentSize