QLPReviewController-不显示捆绑图的图像?
-
04-10-2019 - |
题
这是我的代码...我已经尝试了我能想到的所有路径格式来使它起作用...基本上,我想在快速简便的图片查看器中显示图像...查看器显示(Modally。 。
谢谢你的帮助。 :)
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
QLPreviewController *preview = [[QLPreviewController alloc] init];
[preview setDataSource:self];
[self presentModalViewController:preview animated:YES];
}
#pragma mark QLPreviewController delegate methods
- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller {
return 1;
}
- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {
NSString *imagePath = [NSString stringWithFormat:@"%@",[[NSBundle mainBundle] bundleURL]];
NSString *nextPath = [imagePath stringByAppendingPathComponent:imageName];
NSURL *imageURL = [NSURL URLWithString:nextPath];
return imageURL;
}
解决方案
nsurl *imageurl = [nsurl urlwithstring:nextpath];
nsurl fileurlwithpath:nextpath];
不隶属于 StackOverflow