我想實現一個UIPopoverController能夠共享,但是當UIPopoverController是視圖顯示爲空,我不會有任何錯誤。這是我的代碼:ios ipad UIPopoverController顯示爲空,沒有錯誤
if ([self.activityPopoverController isPopoverVisible]) {
[self.activityPopoverController dismissPopoverAnimated:YES];
} else {
NSString *[email protected]"I'm sharing this image";
NSArray *activityItems = [[NSArray alloc]initWithObjects:self.imgToSend,textToShare,nil];
UIActivityViewController *activityVC=[[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
[email protected][UIActivityTypeAssignToContact,UIActivityTypeCopyToPasteboard ];
activityVC.completionHandler = ^(NSString *activityType, BOOL completed){
[self.activityPopoverController dismissPopoverAnimated:YES];
};
if (self.activityPopoverController) {
[self.activityPopoverController setContentViewController:activityVC];
} else {
self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityVC];
}
[self.activityPopoverController presentPopoverFromRect:[(UIControl *)sender frame]
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
你們中的任何人都可能知道爲什麼這是我的代碼錯了?
我真的很感謝你的幫助。
UPDATE:
我加入這行代碼:
[self.activityPopoverController setPopoverContentSize:self.contentSizeForViewInPopover animated:YES];
,但它看起來都砍掉:
你是否在UIActivityViewController上設置contentSizeInPopover屬性? – sixthcent 2013-04-10 22:50:02
我不是:(我該怎麼做? – HelenaM 2013-04-11 01:05:33
@HelenaM,我不認爲這是原因,請檢查我的答案。 – foundry 2013-04-11 01:22:50