gpt4 book ai didi

ios - 加载 Adob​​e Illustrator(.ai) 文件

转载 作者:可可西里 更新时间:2023-11-01 03:14:57 25 4
gpt4 key购买 nike

是否可以加载 .ai 文件并以编程方式打开它们?

这是我试过的:

- (IBAction)openDocument:(id)sender
{
QLPreviewController *previewController = [[QLPreviewController alloc] init];
[previewController setDataSource:self];
[previewController setDelegate:self];
[self presentModalViewController:previewController animated:YES];
}

- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}

- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
return [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"ai"];
}

但是输出是这样的:

enter image description here

最佳答案

有一种方法可以做到这一点。那就是将该 ai 的扩展名更改为 pdf 并加载它,如下所示,

- (IBAction)openDocument:(id)sender
{
QLPreviewController *previewController = [[QLPreviewController alloc] init];
[previewController setDataSource:self];
[previewController setDelegate:self];
[self presentModalViewController:previewController animated:YES];
}
- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller
{
return 1;
}
- (id <QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
return [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"pdf"];
}

输出:

enter image description here

这工作得很好..但我不想更改扩展名。谁能帮助我更多。

**

更新的答案:

- (IBAction)openDocument:(id)sender
{
UIButton *button = (UIButton *)sender;
NSURL *URL = [[NSBundle mainBundle] URLForResource:@"CNW EXPLODED1" withExtension:@"ai"];

if (URL) {
// Initialize Document Interaction Controller
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];

// Configure Document Interaction Controller
[self.documentInteractionController setDelegate:self];

// Present Open In Menu
[self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES];
}
}


- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self;
}

这显示有菜单选项,但有 BUMP 选项。它仅适用于设备

**

关于ios - 加载 Adob​​e Illustrator(.ai) 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16713714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com