【问题标题】:How to change the size the UIActivityViewController如何更改 UIActivityViewController 的大小
【发布时间】:2014-09-17 13:12:08
【问题描述】:

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

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 的整个屏幕,尽管它只显示了四个共享图标。

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

[更新] 我在真实设备上运行此代码(运行 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 )>"
)

感谢您迄今为止的反馈。

【问题讨论】:

  • 你能分享图片吗?..当我尝试你的代码没有图片和网址时,工作正常,即没有高度问题。所以你可以看看你的图片大小。
  • 请用真机测试..!
  • 作为一个测试,如果您注释掉该行以排除任何活动会发生什么?

标签: ios customization uiactivityviewcontroller


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-08
    • 2012-05-03
    • 2019-03-18
    • 2019-06-11
    • 2013-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多