您的位置:首页 > 移动开发 > IOS开发

iOS文档浏览与文件夹的状态变化的监听

2012-05-18 10:31 441 查看
iOS下的文档浏览以前采用过webview来实现,今天在无意中发现了QuickLook这个框架,是在SDK 3.2中添加的,看了下提供文档预览功能,实际效果类似于webview的展示效果,官方的例子为DocInteraction,其中代码中提到有三种方式:

// three ways to present a preview:
// 1. Don't implement this method and simply attach the canned gestureRecognizers to the cell

//
// 2. Don't use canned gesture recognizers and simply use UIDocumentInteractionController's
// presentPreviewAnimated: to get a preview for the document associated with this cell

//
// 3. Use the QLPreviewController to give the user preview access to the document associated
// with this cell and all the other documents as well.
这段话中的方法1看代码应该是指通过在长按时间出发打开动作,其他两个就是两种显示预览的方式,其中一段求文件大小的代码以后可以用用:

if (size == 0)
formattedStr = @"Empty";
else
if (size > 0 && size < 1024)
formattedStr = [NSString stringWithFormat:@"%qu bytes", size];
else
if (size >= 1024 && size < pow(1024, 2))
formattedStr = [NSString stringWithFormat:@"%.1f KB", (size / 1024.)];
else
if (size >= pow(1024, 2) && size < pow(1024, 3))
formattedStr = [NSString stringWithFormat:@"%.2f MB", (size / pow(1024, 2))];
else
if (size >= pow(1024, 3))
formattedStr = [NSString stringWithFormat:@"%.3f GB", (size / pow(1024, 3))];
还有一个类叫DirectoryWatcher,用于监视目录下文件删除或新增变化的,这个还是蛮不错的,可以学些下
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: