2012-02-29 9 views
1

アムアーカイブおよびアーカイブしないの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)];これはコーディング....

をこの符号化では、すべてのコントロールがあるviewForArchive.subviewsを印刷する....私のアプリケーションでこのコントロールをUIViewのアーカイバである

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!"); 

    } 

をアーカイブ

// (uiimageview、uiscrollview、uitableview、uibutton)は表示されませんでした...このコーディングの問題は何ですか...

+0

私はコードを送信することができますか質問について明確になることができますか? –

+0

いくつかのコードを入力してみてください –

答えて

0

オブジェクトの特定の状態を保存することがポイントであれば、NSUserDefaultsに文字列を格納してあなたの文字列に従ったオブジェクト。あるいは、自動的にオブジェクトを保存するxibファイルを作成できますか?

関連する問題