I'm trying to make a share dialogue for both iPhone and iPad. The iPhone code works, but when I run the iPad version and call this function I get the warning " on whose view is not in the window hierarchy!" How can I display the UIPopover similar to the way I displayed the iPhone? Thanks!
-(void) shareOnlyTextMethod: (const char *) shareMessage: (const char *) shareLink
{
NSString *shareText = [NSString stringWithUTF8String:shareMessage];
NSURL *shareURL = [NSURL URLWithString:[NSString stringWithUTF8String:shareLink]];
NSArray *itemsToShare = @[shareText, shareURL];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityVC];
[popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0)inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else {
[self presentViewController:activityVC animated:YES completion:nil];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:activityVC animated:YES completion:nil];
}
}
Aucun commentaire:
Enregistrer un commentaire