【发布时间】:2013-11-26 16:57:26
【问题描述】:
我的申请被 Apple 拒绝了,原因是:
2.23:应用程序必须遵循 iOS 数据存储指南,否则将被拒绝
那么是否有可能将整个 Document 目录标记为没有备份?我的应用程序在 iOS 6.1 及更高版本中运行。
我对这段代码很熟悉,但我不知道用它来标记我的文档目录
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}
已编辑:
Apple 告诉我 iCloud 会从图片库中备份我的照片,我会像这样加载图库中的图片:
- (void)setupPageScroll {
NSString *imgCount;
int i;
[_scrollView setContentSize:CGSizeMake(_scrollView.frame.size.width * _pageControl.numberOfPages, _scrollView.frame.size.height)];
_scrollView.delegate = self;
for (i = 0 ; i < 10 ; i++) {
imgCount = [NSString stringWithFormat:@"%@%d.jpg",_gallName , i];
[self createPageWithImage:[UIImage imageNamed:imgCount] forPage:i];
}
}
- (void)createPageWithImage:(UIImage *)images forPage:(int)page
{
UIView *newView = [[UIView alloc] initWithFrame: CGRectMake(_scrollView.frame.size.width * page, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];
UIImageView *tempImage = [[UIImageView alloc]initWithImage:images];
[tempImage setContentMode:UIViewContentModeScaleAspectFit];
tempImage.frame = _galleryView.frame;
_imgGallery = tempImage;
[newView addSubview: _imgGallery];
[_scrollView addSubview: newView];
}
- (IBAction)pageChanged:(id)sender {
CGRect pageRect = CGRectMake(_pageControl.currentPage * _scrollView.frame.size.width, 0, _scrollView.frame.size.width, _scrollView.frame.size.height);
[_scrollView scrollRectToVisible: pageRect animated: YES];
}
如何跳过这些图像?
【问题讨论】:
-
- (void)setupPageScroll中 _gallName 的值是多少?看来您的代码前面有一些错误。 -
@WojtekRutkowski 不,这不是错误! _gallName 是一个 NSString 。我的应用程序是关于太阳系的,当用户选择一个行星时,这个字符串会更改为行星的照片名称。
-
根据 iOS 数据存储指南,我的意思是错误。我问过值不是类型,我可以看到它是 NSString。您能在此处插入 _gallName 的实际值吗?
-
我会完全忘记“不备份”属性。当您的应用程序运行时,您正在创建哪些文件?还有,目的是什么?
标签: ios nsfilemanager