在ipad上运行时,iOS共享按钮崩溃

时间:2015-05-11 13:10:04

标签: ios objective-c iphone xcode ipad

我正在使用objective-c中的xcode项目,我想在我的ios应用程序上分享一个共享按钮来分享我在youtube上观看教程的内容链接:https://www.youtube.com/watch?v=zkrOKN_OA_A 但是当我在iphone上运行这个代码时,它运行正常,当我在ipad上运行此代码时,xcode给了我这个错误:

int main(int argc, char * argv[]) {
@autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}}

我使用了这段代码:

- (IBAction)Share1:(id)sender {

UIImage *shareImage = [UIImage imageNamed:@"invoice_logo.png"];
NSArray *itemsToShare = @[shareImage];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = @[];
[self presentViewController:activityVC animated:YES completion:nil];}

2 个答案:

答案 0 :(得分:0)

你错过了:

activityVC.excludedActivityTypes=@[UIActivityTypePostToFacebook,UIActivityTypePostToTwitter]// add your share types

查看您从7:30开始提供的视频

答案 1 :(得分:0)

试试这个:

UIImage *shareImage = [UIImage imageNamed:@"invoice_logo.png"];
NSArray *itemsToShare = @[shareImage];

UIActivityViewController *activityVC = [[UIActivityViewController alloc]
                    initWithActivityItems:itemsToShare applicationActivities:nil];

activityVC.popoverPresentationController.sourceView = self.view;
activityVC.popoverPresentationController.sourceRect = 
           CGRectMake(self.view.bounds.size.width / 2.0, self.view.bounds.size.height-50, 1.0, 1.0);

[self presentViewController:activityVC animated:YES completion:nil];