UIActivity activityViewController being presented modally on iPad instead of in popover

前端 未结 4 1161
误落风尘
误落风尘 2020-12-31 09:03

When using a customer UIActivity subclass in iOS 6, it\'s possible to specify a custom view controller that will be displayed when your action is chosen from the initial UIA

4条回答
  •  鱼传尺愫
    2020-12-31 10:01

    I think the issue with the activity view controller not showing in a popover is a bug and the docs reflect the correct intent. However, I don’t know of a way to workaround this atm.

    The part about dismissing the view controller, however, is a different issue. You are not supposed to dismiss the view controller that you return from -[UIActivity activityViewController], but you are responsible for dismissing the popover that you have presented, which in turn will also remove your custom view controller from the hierarchy. (And because it works this way, I’m inclined to believe that the custom view controller would normally have to be shown in the popover.)

    Here’s an example with code from your example app:

    UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:activityItems
                                                                     applicationActivities:applicationActivities];
    
    vc.completionHandler = ^(NSString *activityType, BOOL completed){
      [self.activityPopoverController dismissPopoverAnimated:YES];
    };
    

提交回复
热议问题