我无法在自定义tableview中显示 UIactivityViewController 。我在表格单元格中有一个按钮。单击该按钮我将显示 UIActonSheet 。点击< strong> UIActionSheet 委托我正在显示 UIActivityController 。当我将源视图设置为主视图时,它可以工作,但是当我将源视图设置为tableview时,它无法正常工作。
以下是代码。
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (actionSheet.tag == 100)
{
if(buttonIndex==0)
{
[self deletePost];
}
else if(buttonIndex==1)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
EditPostController *vc = (EditPostController *)[storyboard instantiateViewControllerWithIdentifier:@"EditPostController"];
HomeCell *cell=(HomeCell *)[self.table_view cellForRowAtIndexPath:unv_indexPath];
if (cell.beizer_image.image!=nil) {
vc.postImage=cell.beizer_image.image;
}
vc.editPost=[arr_post objectAtIndex:unv_index];
[self.navigationController pushViewController:vc animated:true];
}
else if(buttonIndex==2)
{
HomeCell *cell=(HomeCell *)[self.table_view cellForRowAtIndexPath:unv_indexPath];
NSArray *postItems;UIImage *screeshotTaken;
Post *pst=[arr_post objectAtIndex:unv_index];
if (cell.beizer_image.image!=nil) {
screeshotTaken=cell.beizer_image.image;
}
if (screeshotTaken==nil) {
postItems = @[pst.post_title,cell.tv_post.text];
}
else
{
postItems = @[pst.post_title,cell.tv_post.text,screeshotTaken];
}
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:postItems applicationActivities:nil];
if(IS_IPHONE)
{
[self presentViewController:controller animated:YES completion:nil];
}
else
{
controller.popoverPresentationController.sourceView = self.view;
controller.popoverPresentationController.sourceRect = CGRectMake(cell.btn_more.frame.origin.x+20,100 ,0, 0);
[self presentViewController:controller
animated:YES
completion:nil];
}
}
}
else if (actionSheet.tag == 200)
{
if (buttonIndex==0) {
[self reportPostSelection];
}
}
}