I have a design app that allows the user to move images around to create a design. I want them to be able to save their designs.
How would I go about doing this.
Thank you
I have a design app that allows the user to move images around to create a design. I want them to be able to save their designs.
How would I go about doing this.
Thank you
您不能以编程方式生成 xibs/nibs。
我建议您将图像坐标保存为 plist 文件。plist 文件可以包含对象的 NSArray 或 NSDictionary,因此(例如)构建一个坐标数组,如下所示:
NSMutableArray *coordinates = [NSMutableArray array];
for (UIImageView *view in arrayOfImageViews)
{
NSString *position = NSStringFromCGPoint(view.center);
[coordinates addObject:position];
}
[coordinates writeToFile:someFileName atomically:YES];
然后你可以使用相同的方式加载它
NSArray *coordinates = [NSArray arrayWithContentsOfFile:filename];
然后遍历数组并使用它来重新生成图像视图。
显然,这是一个过于简单的示例,因为您还需要在 plist 中包含图像名称和其他数据,但希望您能明白这一点。您的数组可能实际上包含字典,每个字典都包含图像名称和坐标值。