UIActivity popover:如何只显示一行符号?

时间:2015-04-21 15:54:46

标签: ios objective-c uiactivityviewcontroller uipopover

我的应用程序应该在按下按钮时将图片发送到服务器。我选择使用AirDrop,并希望UI尽可能简单。现在我可以排除除AirDrop之外的所有活动,但是popover看起来仍然很混乱:

enter image description here

如何摆脱额外的两条线?他们没有任何目的。

如果有帮助,这里是点击按钮时调用的方法:

- (IBAction)orderButtonTapped:(UIButton *)sender {

    UIImage *image   = [self.detailViewController.paint extractImageFromBitmap];
    UIDevice *device = UIDevice.currentDevice;
    NSArray *items   = @[device.name, image];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:items
                                                                                         applicationActivities:nil];
    activityViewController.excludedActivityTypes = @[UIActivityTypePostToFacebook,
                                                     UIActivityTypePostToTwitter,
                                                     UIActivityTypePostToWeibo,
                                                     UIActivityTypeMessage,
                                                     UIActivityTypeMail,
                                                     UIActivityTypePrint,
                                                     UIActivityTypeCopyToPasteboard,
                                                     UIActivityTypeAssignToContact,
                                                     UIActivityTypeSaveToCameraRoll,
                                                     UIActivityTypeAddToReadingList,
                                                     UIActivityTypePostToFlickr,
                                                     UIActivityTypePostToVimeo,
                                                     UIActivityTypePostToTencentWeibo];
    activityViewController.popoverPresentationController.sourceView = self.view;

// if iPhone
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        [self presentViewController:activityViewController animated:YES completion:nil];
    }

// if iPad
    else {
        CGFloat xPos = self.orderButton.frame.origin.x + self.orderButton.frame.size.width/2;
        CGFloat yPos = self.orderButton.frame.origin.y;
        UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
        [popup presentPopoverFromRect:CGRectMake(xPos, yPos, 0, 0)
                               inView:self.view
             permittedArrowDirections:UIPopoverArrowDirectionAny
                             animated:YES];
    }
}

1 个答案:

答案 0 :(得分:0)

您不能。用户可以在那里进行自定义第三方活动。您不能仅将所选活动(例如AirDrop)列入白名单,而只能将其中一些活动列入黑名单。你正在做的是什么。