How to change the size the UIActivityViewController

会有一股神秘感。 提交于 2019-12-08 10:00:58

问题


In my app, I want to share an image, text and url. I do that as follows:

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];

Unfortunately, as a result, the modal dialog covers the whole screen of my iphone, although it only displays four share icons.

I think that is out of proportion, and would like to adjust the height of the controller, so it only accommodates that one needed row.

[Update] I am running this code on a real device (iPhone 5s running the very latest beta of iOS 8), and the size of the image doesn't seem to matter. However, in my console I see the following messages, that should help to fix the issue.

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 )>"
)

Thanks for your feedback so far.


回答1:


I just upgraded my Xcode from beta to release 6.01 and the problem disappeared. Thanks for your patience..



来源:https://stackoverflow.com/questions/25891574/how-to-change-the-size-the-uiactivityviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!