iOS 共享扩展未显示我的自定义 ShareViewController

iOS Share Extension not presenting my custom ShareViewController

我似乎无法展示我的自定义 ShareViewController。我继承了 UIViewController,而不是 SLComposeViewController,将它添加到 Storyboard,但是当我 select 要共享的图像时,没有显示 ShareViewController。这是我的全部代码:

头文件:

#import <UIKit/UIKit.h>
#import <Social/Social.h>

@interface ShareViewController : UIViewController

@end

执行文件:

@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

断点表示运行时确实执行了代码,甚至抓取了图像,但由于某种原因没有显示自定义视图控制器。有帮助吗?

这太愚蠢了,我花了一段时间才弄明白,但出于某种原因,默认情况下,自定义 ShareViewController 视图的背景颜色设置为 [UIColor clearColor]。苹果真蠢:),但我解决了这个案子