如何更改UIActivityViewController的大小

时间:2014-09-17 13:12:08

标签: ios customization uiactivityviewcontroller

在我的应用中,我想分享图片,文字和网址。我这样做如下:

UIActivityViewController *controller =  [[UIActivityViewController alloc]
                                             initWithActivityItems:@[text, url, image]
                                             applicationActivities:nil];

    controller.excludedActivityTypes = @[UIActivityTypePostToWeibo,
                                         //UIActivityTypeMessage,
                                         //UIActivityTypeMail,
                                         UIActivityTypePrint,
                                         UIActivityTypeCopyToPasteboard,
                                         UIActivityTypeAssignToContact,
                                         UIActivityTypeSaveToCameraRoll,
                                         UIActivityTypeAddToReadingList,
                                         UIActivityTypePostToFlickr,
                                         UIActivityTypePostToVimeo,
                                         UIActivityTypePostToTencentWeibo,
                                         UIActivityTypeAirDrop];

    [self presentViewController:controller animated:YES completion:nil];

不幸的是,因此,模态对话框覆盖了我的iphone的整个屏幕,尽管它只显示了四个共享图标。

my screen shot

我认为这是不成比例的,并且想要调整控制器的高度,所以它只适应那个需要的行。

[更新] 我在真实设备上运行此代码(运行iOS 8最新测试版的iPhone 5s),图像的大小似乎并不重要。但是,在我的控制台中,我看到以下消息,这应该有助于解决问题。

2014-09-17 15:24:27.068 AppName[1826:747596] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x17008a5a0 UIView:0x1781945d0.bottom == _UIAlertControllerView:0x13c51ea00.bottom>",
    "<NSLayoutConstraint:0x17008aeb0 V:|-(0)-[UIView:0x178194d20]   (Names: '|':_UIAlertControllerView:0x13c51ea00 )>",
    "<NSLayoutConstraint:0x17008af50 UIView:0x178194d20.bottom <= _UIAlertControllerView:0x13c51ea00.bottom>",
    "<NSLayoutConstraint:0x17008afa0 UIView:0x1781945d0.centerY == UIView:0x178194d20.centerY>",
    "<NSLayoutConstraint:0x17008a550 V:|-(>=8)-[UIView:0x1781945d0]   (Names: '|':_UIAlertControllerView:0x13c51ea00 )>"
)

感谢您的反馈。

1 个答案:

答案 0 :(得分:0)

我刚刚将我的Xcode从beta版升级到版本6.01,问题就消失了。 谢谢你的耐心......