Reputation: 491
I have a UITableView
in a UIViewController
that is embedded in a Navigation Controller. The UIViewController
is arranged using Auto Layout. I am using SWTableViewCell to enable swipe left-to-right. This displays a 'share' button which displays a UIActivityViewController
when tapped.
The problem is, the UIActivityViewController
displays incorrectly when called, squished to the left side of the view and attached to the top left corner. See images below for example, the first is during display of the UIActivityViewController
, and the second is once the UIActivityViewController
is displayed.
I haven't been able to find any other posts about this type of issue. The code below is how I call the UIActivityViewController
from the - (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index
method of SWTableViewCell
delegate.
WhatsAppMessage *whatsappMsg = [[WhatsAppMessage alloc] initWithMessage:shareItem forABID:nil];
NSArray *activityItems = @[shareItem, whatsappMsg];
NSArray *applicationActivities = @[[[JBWhatsAppActivity alloc] init],[[LINEActivity alloc] init], [[WeixinTimelineActivity alloc] init],[[WeixinSessionActivity alloc] init]];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityViewController.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList, UIActivityTypePostToVimeo, UIActivityTypePostToFlickr, UIActivityTypeAirDrop];
[self.navigationController presentViewController:activityViewController animated:YES completion:^{}];
Any ideas?
Upvotes: 1
Views: 710
Reputation: 491
I finally found the answer and I knew it had something to do with auto layout. Earlier in the project I had most of my auto layout constraints set in code and I had put the following line in my AppDelegate.m file:
self.window.translatesAutoresizingMaskIntoConstraints = NO;
After removing this line, the UIActivityViewController
loads perfectly!
Hopefully this helps others who run into this issue.
Upvotes: 1