objective-c presentViewController位置
objective-c presentViewController position
所以我有这样的 UIActivityViewConroller:
- (IBAction)Share:(id)sender {
NSData *pdfData = [NSData dataWithContentsOfFile:self.pdfPath];
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:@[pdfData] applicationActivities:nil];
activityController.popoverPresentationController.sourceView = self.NavBar;
[self presentViewController:activityController animated:YES completion:nil];
}
我的问题是它显示在 self.NavBar 的左侧,我想将它放在右侧,我该怎么做?
使用 UIPopoverController
和 presentPopoverFromRect
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:postItems applicationActivities:nil];
UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:controller];
[popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0)inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
根据需要更改 CGRect
的位置。
所以我有这样的 UIActivityViewConroller:
- (IBAction)Share:(id)sender {
NSData *pdfData = [NSData dataWithContentsOfFile:self.pdfPath];
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:@[pdfData] applicationActivities:nil];
activityController.popoverPresentationController.sourceView = self.NavBar;
[self presentViewController:activityController animated:YES completion:nil];
}
我的问题是它显示在 self.NavBar 的左侧,我想将它放在右侧,我该怎么做?
使用 UIPopoverController
和 presentPopoverFromRect
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:postItems applicationActivities:nil];
UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:controller];
[popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0)inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
根据需要更改 CGRect
的位置。