Reputation: 921
I cant seem to present my custom ShareViewController. I inherited UIViewController, not SLComposeViewController, added it to the Storyboard, but when i select an image to share, ShareViewController is not presented. Here is my entire code:
Header file:
#import <UIKit/UIKit.h>
#import <Social/Social.h>
@interface ShareViewController : UIViewController
@end
Implementation file:
@implementation ShareViewController
- (void)viewDidLoad{
[super viewDidLoad];
self.view.alpha = 0;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.view.transform = CGAffineTransformMakeTranslation(0, self.view.frame.size.height);
[UIView animateWithDuration:0.25 animations:^
{
self.view.transform = CGAffineTransformIdentity;
}];
}
- (void)dismiss
{
[UIView animateWithDuration:0.20 animations:^
{
self.view.transform = CGAffineTransformMakeTranslation(0, self.view.frame.size.height);
}
completion:^(BOOL finished)
{
[self.extensionContext completeRequestReturningItems:nil completionHandler:nil];
}];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:YES];
for (NSItemProvider* itemProvider in ((NSExtensionItem*)self.extensionContext.inputItems[0]).attachments )
{
if([itemProvider hasItemConformingToTypeIdentifier:@"public.image"])
{
[itemProvider loadItemForTypeIdentifier:@"public.image" options:nil completionHandler:
^(id<NSSecureCoding> item, NSError *error)
{
UIImage *sharedImage = nil;
if([(NSObject*)item isKindOfClass:[NSURL class]])
{
sharedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:(NSURL*)item]];
}
if([(NSObject*)item isKindOfClass:[UIImage class]])
{
sharedImage = (UIImage*)item;
}
}];
}
}
}
@end
Breakpoint indicates that runtime does execute the code, even grabs image, but the custom view controller is not presented for some reason. Any help?
Upvotes: 2
Views: 1084
Reputation: 921
It was so stupid and it took me a while to figure it out, but for some reason, by default, custom ShareViewController view's background color is set to [UIColor clearColor]. Very stupid of Apple :), but i solved this case
Upvotes: 4