'는' 크리스티비티비스콘트로예르 너희는너희가 찾고 있다.
내가 너 때문에 일반 can& # 39, t 보다 더 많은 일을 묻는 질문에 대한 링크를 제공하십시오 [문서용으로] (https://developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html)
그 외에, 작은 부분을 수락됨 예제 코드
- (void)shareText:(NSString *)text andImage:(UIImage *)image andUrl:(NSURL *)url
{
NSMutableArray *sharingItems = [NSMutableArray new];
if (text) {
[sharingItems addObject:text];
}
if (image) {
[sharingItems addObject:image];
}
if (url) {
[sharingItems addObject:url];
}
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
}
[self shareText:@"Hello world" andImage:nil andUrl:nil];
몇 가지 좋은 예제 코드: https://stackoverflow.com/questions/13498459/how-to-display-the-default-ios-6-share-action-sheet-with-available-share-options
이 질문은, 코드는 특정 그러니까말이야 iOS 7 은 iOS 6 있지만, 그들은 매우 유사한 예제에서와 아파리스트 예제 코드 tpc. 도움됐네 믿엇어요 것으로 한 알 수 있습니다
'는' 크리스티비티비스콘트로예르 너희는너희가 찾고 있다.
이 항목이거나 응용 프로그램을 지정할 수 있습니다
UIActivityViewController *actCont = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
그냥 '에 대해 다음과 같은 코드를 사용할 수 있습니다 기본 Sharing. 샤이테마스 어레이입니다 요구사항에 따라' 항목을 더 추가할 수 있습니다.
NSMutableArray *shareItems = [[NSMutableArray alloc] initWithObjects:
@"Hello",
[UIImage imageNamed:@"your_image.png"],
@"http://google.com/", nil];
[self shareItemToOtherApp:shareItems];
다음과 같은 방법을 사용할 기본 텍스트 또는 다른 어플리케이션 - 로 이미지 공유
-(void)shareItemToOtherApp:(NSMutableArray *)shareItems{
UIActivityViewController *shareController = [[UIActivityViewController alloc]
initWithActivityItems: shareItems applicationActivities :nil];
[shareController setValue:@"Sharing" forKey:@"subject"];
shareController.excludedActivityTypes = @[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeSaveToCameraRoll];
shareController.completionHandler = ^(NSString *activityType, BOOL completed)
{
//NSLog(@" activityType: %@", activityType);
//NSLog(@" completed: %i", completed);
};
[self presentViewController: shareController animated: YES completion: nil];
}
-(void)shareOnFacebook:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *faceSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
// NSLog(@"%@", messageField.text);//This returns the appropriate string
[faceSheet setInitialText:@"Hellooooooo"];
//The facebook VC appears, but initial text is not set to messageField.text
[self presentViewController:faceSheet animated:YES completion:nil];
}
else
{
NSLog(@"Please first install Application and login in Facebook");
}
}
-(void)shareOnTwitter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:@"Hello"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
else{
NSLog(@"Please first install Application and login in Twitter");
}
}