【发布时间】:2012-03-18 16:15:01
【问题描述】:
我归档并取消归档 uiview 并在 ipad 中显示视图此控件(uiimageview、uiscrollview、uitableview、uibutton)未显示....但是 uiview 子视图所有控件都在那里....是否有可能得到那个视图中的控件(uiimageview、uiscrollview、uitableview、uibutton)?可能意味着如何让该控件显示在视图中。
uiview *viewForArchive; uiview *newCir=[uiview alloc ]initwithframe:cgrectmake(0,0,768,1024)];
//归档
NSMutableData *d= [NSMutableData data];
NSKeyedArchiver *kA=[[NSKeyedArchiver alloc] initForWritingWithMutableData:d];
[kA encodeObject:newCir forKey:@"view"];
[kA finishEncoding];
if ([d writeToFile:[NSHomeDirectory() stringByAppendingPathComponent:@"archiveView"] options:NSAtomicWrite error:nil] == NO)
{
NSLog(@"writeToFile error");
}
else
{
NSLog(@"Written!");
}
//unarchiving
NSData *theData = [NSData dataWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"archiveView"]];
NSKeyedUnarchiver *decoder = [[NSKeyedUnarchiver alloc] initForReadingWithData:theData];
NSDictionary *dict= [decoder decodeObjectForKey:@"view"];
[decoder finishDecoding];
if ([theData writeToFile:[NSHomeDirectory() stringByAppendingPathComponent:@"unarchiveView"] options:NSAtomicWrite error:nil] == NO) {
NSLog(@"writeToFile error");
}
else {
if ([dict isKindOfClass:[UIView class]]) {
viewForArchive=(UIView *)dict;
NSLog(@"view:%@",viewForArchive.subviews );
viewForArchive.backgroundColor=[UIColor whiteColor];
[self.view addsubview:viewForArchive];
}
NSLog(@"Written!");
}
这是 uiview 归档器编码....
在这个打印viewForArchive.subviews的编码中,所有控件都在那里......在我的应用程序中,这个控件(uiimageview,uiscrollview,uitableview,uibutton)没有显示......这个编码有什么问题......
【问题讨论】:
-
我无法让您发送代码或明确问题?
标签: objective-c uiview ios5