【问题标题】:How to display two buttons in popoverview - WEPOPOVER如何在 popoverview 中显示两个按钮 - WEPOPOVER
【发布时间】:2012-09-05 09:20:44
【问题描述】:

我想在 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];    

【问题讨论】:

    标签: iphone ios ios4


    【解决方案1】:

    您为两个按钮提供了相同的框架。所以它只显示一个按钮。

    [editBtn setFrame:CGRectMake(250, 0, 100,40)];
    
    [deleteBtn setFrame:CGRectMake(250, 0, 100,40)];
    

    【讨论】:

      猜你喜欢
      • 2021-05-18
      • 2021-07-03
      • 2020-04-07
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 1970-01-01
      相关资源
      最近更新 更多