2012-04-12 16 views
5

Çizim Çizgileri'ni kalıcı olarak Kaydet ve Project kaynaklarından kaydedilmiş Çizim çizgilerini yüklemek istiyorum!Kaydetme ve Yükleme Çizim çizgileri iphone SDK

Şimdi, x ve y konumuna dokunma hareketine geçiyorum event.i bir projede yerel kaynakta x ve y konumunu kaydetmek istiyorum, ama ios konusunda deneyimsiz değilim ...!

Ve Yük Kaydedilen x ve y konumunu proje yerel kaynak kayıtlı dosyasından ..!

böyle Aşağıda çizgiler çizme kaydet istiyorum:

enter image description here

Büyük takdir herhangi biri bana yardımcı olun lütfen ...!

Teşekkürler!

cevap

2

Eğer x ve y konumlarını saklamak isterseniz, bir diziyi saklayabilir ve writeToFile ile diske kaydedebilirsiniz. Bu verileri diske plist formatında yazacaktır.

NSMutableArray *points = ... 
[points writeToFile:someFileInTheBundle atomically:YES]; 

Ayrıca bir görüntü olarak çizim depolamak ve diske olduğunu yazabiliriz. Yazdığım Bu kategori çizim kodu için size bir resim vererek bu konuda yardımcı olacaktır: o defenatly ur soru çözecek https://github.com/kgn/BBlock/blob/master/UIImage%2BBBlock.m

3
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 

    if(!mouseSwiped) { 
     CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeClear); 
     UIGraphicsBeginImageContext(ivBack.frame.size); 
     [drawImage.image drawInRect:CGRectMake(0,0, self.ivBack.frame.size.width,self.ivBack.frame.size.height)]; 
     CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
     CGContextSetLineWidth(UIGraphicsGetCurrentContext(), line); 
     CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [pickColor CGColor]); 
     CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
     CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
     CGContextStrokePath(UIGraphicsGetCurrentContext()); 
     CGContextFlush(UIGraphicsGetCurrentContext()); 

NSData *dataImage=UIImagePNGRepresentation(UIGraphicsGetImageFromCurrentImageContext()); 
     [dataImage writeToFile:[self SavedImage:(@"1.png")] atomically:YES]; 
     drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
     UIGraphicsEndImageContext(); 
    } 
} 

İlgili konular