我不断收到一个错误
问题描述:
我一直在打码时得到popovercontroller错误,这里是我的代码:我不断收到一个错误
- (IBAction)sharePost:(id)sender {
NSArray *activityItems;
NSInteger tid = ((UIControl *) sender).tag;
if ([catName isEqualToString:@"All"])
{
//UIImage *snapshotImage = [self imageFromView:self.view];
activityItems = @[[self.titleArray objectAtIndex:tid],[self.linkArray objectAtIndex:tid],[self.imageArray objectAtIndex:tid]];
}
else
{
activityItems = @[[self.titleCatArray objectAtIndex:tid],[self.linkCatArray objectAtIndex:tid],[self.imageCatArray objectAtIndex:tid]];
}
UIActivityViewController *activityController =
[[UIActivityViewController alloc]
initWithActivityItems:activityItems
applicationActivities:nil];
[self presentViewController:activityController
animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
我想要得到它的工作在iPad上,我有在网上看了一切,但无法弄清楚。
答
在文档UIActivityViewController:
在iPad上,你必须在酥料饼呈现视图控制器。在iPhone和iPod touch上,您必须以模态形式呈现它。
尝试:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:activityController];
[popover presentPopoverFromRect:[sender bounds]
inView:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
self.popover = popover;
} else {
[self presentViewController:activityController
animated:YES
completion:nil];
}
现在快到了警告: –
警告:加入后使用didReceiveMemoryWarning未声明的标识符的这个 –
你有一个'}'为sharePost的'结束:'在'}'结束'else'子句之后? – Mats