其实系统分享实现很简单,只需要几行代码就可以啦,主要是还要在info里面配置一些小东西,忽略了就会报错了。
两张图片教会你做系统分享:
1.在需要时写下以下代码
2.在info中配置Supported
NSData* data = [NSDatadataWithContentsOfURL:[NSURLURLWithString:@“这里加载网络图片”]];
UIImage*image=[UIImageimageWithData:data];
NSURL*url = [NSURLURLWithString:@“URL”];
NSArray*postItems=@[info,image,url];
UIActivityViewController*controller = [[UIActivityViewControlleralloc]initWithActivityItems:postItemsapplicationActivities:nil];
controller.excludedActivityTypes=@[UIActivityTypePostToFacebook];
if(UI_USER_INTERFACE_IDIOM() ==UIUserInterfaceIdiomPhone) {//if iPhone
[selfpresentViewController:controlleranimated:YEScompletion:nil];
}
else{//if iPad
UIBarButtonItem*shareBarButtonItem =self.navigationItem.leftBarButtonItem;
UIPopoverController*popup = [[UIPopoverControlleralloc]initWithContentViewController:controller];
[popuppresentPopoverFromBarButtonItem:shareBarButtonItempermittedArrowDirections:UIPopoverArrowDirectionAnyanimated:YES];
}