我的存檔和unarchive uiview並顯示在ipad中的視圖這個控件(uiimageview,uiscrollview,uitableview,uibutton)沒有顯示....但uiview子視圖全部控制在那裏....是否有可能得到該控件(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)沒有顯示......這個編碼有什麼問題...
我無法得到你可以發送代碼或明確的問題? – 2012-02-29 07:15:09
嘗試放入一些代碼 – 2012-02-29 08:33:43