所有显示都是以编程方式设置的,1问题如何以编程方式设置以下代码
NSArray *objectsToShare;
NSString* shareText = @"hey check out this new app on App Store";
NSURL *website = [NSURL URLWithString:[NSString stringWithFormat:@"%s", "http://www.lmg.co.za"]];
objectsToShare = @[shareText, website];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = @[UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo,
UIActivityTypePostToTwitter,
UIActivityTypePostToWeibo,
UIActivityTypePostToTencentWeibo,
UIActivityTypePrint,
UIActivityTypeAirDrop,
UIActivityTypeAssignToContact,
UIActivityTypeCopyToPasteboard];
activityVC.excludedActivityTypes = excludeActivities;
if ([activityVC respondsToSelector:@selector(popoverPresentationController)]) {
activityVC.popoverPresentationController.sourceView = self.view;
activityVC.popoverPresentationController.sourceRect = [(UIButton *)sender frame];
}
[NavigationController presentViewController:activityVC animated:YES completion:nil];
如果我应该添加一个单独的视图控制器,请告诉我
提前谢谢
答案 0 :(得分:-1)
下面的行
[NavigationController presentViewController:activityVC animated:YES completion:nil];
使用
[self presentViewController:activityVC animated:YES completion:nil];
答案 1 :(得分:-1)
NSString * title =[NSString stringWithFormat:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry."];
NSArray* dataToShare = @[title];
UIActivityViewController* activityViewController =[[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];