小编Bat*_*nom的帖子

SQLite"数据库磁盘映像格式错误"

我在使用SQLite数据库损坏的应用程序时遇到问题.之前有一个奇怪的例子,但在iOS 7.1发布后它似乎变得更加普遍.

我正在使用Matteo Bertozzi的SQLite包装器,你可以在这里找到:https://github.com/ConnorD/simple-sqlite

数据库损坏并吐出错误database disk image is malformed,可以运行一些查询但现有数据搞砸了.

我已经搜索了高低,无法找到解决方案,我希望有人在这里有一些想法,因为这是iOS更新后的一个更常见的问题.

我试过这些修复命令:

[sqlite executeNonQuery:@"pragma integrity_check"];
[sqlite executeNonQuery:@"reindex nodes"];
[sqlite executeNonQuery:@"reindex pristine"];
Run Code Online (Sandbox Code Playgroud)

输出是:

SQLite Step Failed: database disk image is malformed
SQLite Prepare Failed: unable to identify the object to be reindexed
 - Query: reindex nodes
SQLite Prepare Failed: unable to identify the object to be reindexed
 - Query: reindex pristine`
Run Code Online (Sandbox Code Playgroud)

通过进一步的挖掘,我发现了这个问题:核心数据和iOS 7:持久存储的不同行为,它提到了iOS7之后SQLite的问题.

虽然我不知道如何使用NSPersistentStore,所以我试着跑[sqlite executeNonQuery:@"pragma journal_mode = DELETE"];,它只是说SQLite …

sqlite objective-c wrapper ios ios7.1

10
推荐指数
1
解决办法
2万
查看次数

UIGraphicsGetImageFromCurrentImageContext() - 内存泄漏

我正在打开相机UIImagePickerControllerSourceTypeCamera和自定义,cameraOverlayView所以我可以拍摄多张没有"使用照片"步骤的照片.

这很好用,但保存照片功能中存在内存泄漏.通过大量的调试和研究,我将其缩小到了UIGraphicsGetImageFromCurrentImageContext功能.

以下是代码片段:

UIGraphicsBeginImageContextWithOptions(timestampedImage.frame.size, timestampedImage.opaque, [[UIScreen mainScreen] scale]);
[[timestampedImage layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *finalTimestampImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

我已经浏览了互联网,似乎该UIGraphicsGetImageFromCurrentImageContext()功能(引自这个SO问题)"返回一个新的自动释放UIImage并将finalTimestampImageivar指向它.先前分配UIImage的实际上从未被释放,它的变量只是被重新命名到其他地方."

我尝试了很多显然适用于其他人的解决方案:

  • timestampedImage.layer.contents = nil;之后添加UIGraphicsEndImageContext

  • 添加CGContextRef context = UIGraphicsGetCurrentContext();CGContextRelease(context);之后UIGraphicsEndImageContext

  • 将上述片段包装成一个 NSAutoreleasePool

  • 将整个saveThisPhoto功能包装成一个NSAutoreleasePool

  • 创建NSAutoreleasePool时相机弹出并调用[pool release]didReceiveMemoryWarning被调用

  • didReceiveMemoryWarning调用时关闭相机弹出窗口,希望它能清除游泳池

  • 以上每种可能的组合

然而,我尝试的一切,当我拍照时,我可以看到Memory Utilized当我在设备上反复拍照时,上升而不是下降.

有谁知道如何释放由自己创建的自动释放对象UIGraphicsGetImageFromCurrentImageContext

或者,有没有另一种方法来制造UIImage一个UIImageView

编辑:

以下是所要求的全部功能.在那里添加了很多额外的释放只是为了确保 …

memory-leaks objective-c ios

7
推荐指数
1
解决办法
6637
查看次数

cellForRowAtIndexPath未被调用

我有一个视图,以这种方式在顶部添加另一个视图:

- (void)showAreaEditView {

    NSLog(@"SHOWING AREA EDITOR VIEW");

    if (self.thisAreaEditorView == nil) {

        // Create View
        AreaEditorView *tmpViewController = [[AreaEditorView alloc] initWithNibName:@"AreaEditorView" bundle:nil];
        self.thisAreaEditorView = tmpViewController;
        [tmpViewController release];

        // Hide the back button
        self.thisAreaEditorView.navigationItem.hidesBackButton = YES;

    }

    self.thisAreaEditorView.myInspectionID = self.myInspectionID;
    self.thisAreaEditorView.loggedIn = loggedIn;
    self.thisAreaEditorView.loggedInGroup = loggedInGroup;

    // Slide view up

    [self.view addSubview:thisAreaEditorView.view];


    CGRect endFrame = CGRectMake(self.view.frame.size.width/2 - thisAreaEditorView.view.frame.size.width/2,
                                 self.view.frame.size.height/2 - thisAreaEditorView.view.frame.size.height/2, 
                                 thisAreaEditorView.view.frame.size.width, 
                                 thisAreaEditorView.view.frame.size.height);

    CGRect startFrame = endFrame; // offscreen source

    // new view starts off bottom of screen
    startFrame.origin.y += …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uitableview

2
推荐指数
1
解决办法
9903
查看次数

标签 统计

objective-c ×3

ios ×2

ios7.1 ×1

memory-leaks ×1

sqlite ×1

uitableview ×1

wrapper ×1

xcode ×1