2015-09-04 274 views
-1

在我的應用程序中有共享選項,所以我想在工作表中打開該共享選項。 如何實現這個功能?如何在iOS的UIActionSheet中設置imageview

NSArray * itemsArray = @[@"www.google.com", @"Google", @"5.png"]; // Anything you want to share 
NSArray * applicationActivities = nil; 

UIActivityViewController * activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsArray applicationActivities:applicationActivities]; 

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) 
{ 
    activityViewController.popoverPresentationController.sourceView = self.view; 
} 
[self presentViewController:activityViewController animated:YES completion:nil]; 

我要指派自己的自定義圖像,鏈接和文本因此如何實現這一

enter image description here

+0

請發表你的努力 – iAnurag

+0

請我上傳的圖片 –

回答

1

你爲什麼不使用UIActivityViewController呢?因此,該系統可以處理在哪裏分享:

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 


UIImage * image = [UIImage imageNamed:@"yourimage.png"]; 
NSArray * itemsArray = @[image]; // Anything you want to share 


    NSArray * applicationActivities = nil; 

    UIActivityViewController * activityViewController = [[UIActivityViewController alloc] initWithActivityItems:itemsArray applicationActivities:applicationActivities]; 

    activityViewController.excludedActivityTypes = @[ 
                UIActivityTypePostToWeibo, 
                UIActivityTypeAssignToContact, 
                UIActivityTypeAirDrop, 
                UIActivityTypeAddToReadingList 
                // Whatever you want to exclude 
                ]; 

    if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")){ 
     activityViewController.popoverPresentationController.sourceView = self.view; 
    } 

    [self presentViewController:activityViewController animated:YES completion:nil]; 
+0

的NSArray * itemsArray = @ [URL? url:[NSNull null],標題?標題:[NSNull null],圖像? image:[NSNull null]]; if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@「8.0」)){activity_Controller.popoverPresentationController.sourceView = viewController.view; } [viewController presentViewController:activityViewController animated:YES completion:nil]; 在這一行中出現錯誤 –

+0

替換對象的'url','title'和'image'。實際上,只需在陣列中添加你想分享的內容即可。 –

+0

我不能得到.... –

相關問題