ios - 我们如何在 iPhone sdk 中从 Evernote 导入图像
<p><p>我正在开发一个绘图工具项目的应用程序,我们需要将印象笔记帐户中的图像导入我的应用程序。</p>
<p>我正在使用下面的代码来获取笔记列表。但我无法解码“data.bodyHash”NSData 并且图像变为 nil。您可以在下面的代码中看到。</p>
<pre><code>EvernoteSession *session = ;
EDAMNoteFilter* filter = [ initWithOrder:0 ascending:NO words:nil notebookGuid:nil tagGuids:nil timeZone:nil inactive:NO emphasized:nil];
[ findNotesWithFilter:filter offset:0 maxNotes:100 success:^(EDAMNoteList *list) {
for (EDAMNote *note in list.notes) {
NSLog(@"Notes : %@",note.title);
NSMutableArray *resources = note.resources;
if (resources!=nil) {
EDAMResource* resource = ;
EDAMData *data = resource.data;
UIImage *image = [initWithData:data.bodyHash];
/// Image is nil
}
}
}
</code></pre>
<p>谢谢</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>是的,这是可能的。您应该采取一些步骤来达到预期的效果。</p>
<p>1) 确保您的 Evernote 应用程序对用户的 Evernote 帐户具有完全访问权限,以便能够阅读现有笔记(您可以在 <a href="https://dev.evernote.com" rel="noreferrer noopener nofollow">https://dev.evernote.com</a> 上请求 Evernote API Key 时进行设置)</p>
<p>2) 认证</p>
<pre><code>[self.session authenticateWithViewController:self
preferRegistration:NO
completion:^(NSError* authenticateError) {
...
}];
</code></pre>
<p>3) 查找所有笔记</p>
<pre><code>[self.session findNotesWithSearch:nil
inNotebook:nil
orScope:ENSessionSearchScopeAll
sortOrder:ENSessionSortOrderNormal
maxResults:255
completion:^(NSArray* findNotesResults,
NSError* findNotesError) {
...
}];
</code></pre>
<p>4) 下载每条笔记</p>
<pre><code>for (ENSessionFindNotesResult* result in findNotesResults) {
[self.session downloadNote:result.noteRef
progress:NULL
completion:^(ENNote* note,
NSError* downloadNoteError) {
...
}];
}
</code></pre>
<p>5) 获取所有图片</p>
<pre><code>for (ENResource* resource in note.resources) {
if () {
UIImage* image = [ initWithData:resource.data];
...
}
}
</code></pre>
<p>您可以查看<a href="https://dl.dropboxusercontent.com/u/930742/so/EvernoteTest.zip" rel="noreferrer noopener nofollow">sample project here</a> .<br/>
如果你设置了消费者 key 和 secret ,在认证之后你会看到类似的控制台输出:</p>
<pre><code>2014-08-19 22:54:18.782 EvernoteTest finding all notes..
2014-08-19 22:54:20.356 EvernoteTest processing find notes results..
2014-08-19 22:54:21.294 EvernoteTest getting images from note 'Just Image'
2014-08-19 22:54:21.294 EvernoteTest >> image with size {600, 400}
2014-08-19 22:54:21.295 EvernoteTest
2014-08-19 22:54:21.720 EvernoteTest getting images from note 'Getting Started'
2014-08-19 22:54:21.721 EvernoteTest >> image with size {27, 27}
2014-08-19 22:54:21.721 EvernoteTest >> image with size {215, 54}
2014-08-19 22:54:21.722 EvernoteTest >> image with size {300, 300}
2014-08-19 22:54:21.722 EvernoteTest >> image with size {27, 27}
2014-08-19 22:54:21.723 EvernoteTest >> image with size {27, 27}
2014-08-19 22:54:21.723 EvernoteTest >> image with size {27, 27}
2014-08-19 22:54:21.724 EvernoteTest >> image with size {27, 27}
2014-08-19 22:54:21.724 EvernoteTest >> image with size {27, 27}
2014-08-19 22:54:21.725 EvernoteTest >> image with size {27, 27}
2014-08-19 22:54:21.725 EvernoteTest
2014-08-19 22:54:22.179 EvernoteTest getting images from note 'Another Image'
2014-08-19 22:54:22.180 EvernoteTest >> image with size {685, 514}
2014-08-19 22:54:22.180 EvernoteTest
</code></pre>
<p>希望对你有帮助</p></p>
<p style="font-size: 20px;">关于ios - 我们如何在 iPhone sdk 中从 Evernote 导入图像,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/25363778/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/25363778/
</a>
</p>
页:
[1]