【问题标题】:How to add UIView in UIPopoverViewController?如何在 UIPopoverViewController 中添加 UIView?
【发布时间】:2012-02-01 11:48:23
【问题描述】:

如何将 UIView 添加到 UIPopoverViewController 中

【问题讨论】:

    标签: ipad


    【解决方案1】:
    -(void) buttonAction:(id)sender {
        //build our custom popover view
    
           UIViewController* popoverContent = [[UIViewController alloc]
    
                          init];
    
           UIView* popoverView = [[UIView alloc]
    
                          initWithFrame:CGRectMake(0, 0, 200, 300)];
    
           popoverView.backgroundColor = [UIColor whiteColor];
    
           popoverContent.view = popoverView;
    
    
        //resize the popover view shown
        //in the current view to the view's size
    
           popoverContent.contentSizeForViewInPopover =
    
                          CGSizeMake(200, 300);
    
    
        //create a popover controller
    
           self.popoverController = [[UIPopoverController alloc]
    
                       initWithContentViewController:popoverContent];
    
    
        //present the popover view non-modal with a
        //refrence to the button pressed within the current view
        [self.popoverController presentPopoverFromRect:popoverButton.frame
    
                       inView:self.view
    
                       permittedArrowDirections:UIPopoverArrowDirectionAny
    
                       animated:YES];
    
    
        //release the popover content
        [popoverView release];
        [popoverContent release];
        }
    
    This will add the view to your UIPopoverViewController
    

    【讨论】:

      【解决方案2】:

      您可以查看下面的链接以了解如何执行此操作

      Are there examples of how to use UIPopoverController on iOS?

      【讨论】:

        【解决方案3】:

        试试下面的代码:

        if (mycontroller == nil) {
                    MyController * viewController = [[MyController alloc] initWithNibName:@"ControllerView" bundle:nil];
        
        
        
                    mycontroller = viewController;
                    PopoverController = [[UIPopoverController alloc] initWithContentViewController:self.mycontroller];    
                    PopoverController.delegate = self;
            }
        
         [PopoverController presentPopoverFromRect:CGRectMake(260, 120, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-03-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-10-29
          • 2016-05-16
          • 1970-01-01
          相关资源
          最近更新 更多