0
我添加了縮放以將手勢旋轉到UIImageView(myImageView)。縮放和旋轉後,有應用按鈕保存圖像。以下是應用方法。它以正確的旋轉和縮放來正確保存圖像。就像截圖一樣。圖像在縮放和旋轉後根據UIImage的框架未顯示
UIGraphicsBeginImageContextWithOptions(view.frame.size,view.opaque,0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data=UIImageJPEGRepresentation(viewImage, 100);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *strPath = [documentsDirectory stringByAppendingPathComponent:@"BorderedImage.jpg"];
[data writeToFile:strPath atomically:YES];
但這樣做後,我將保存的圖像重新分配給myImageView。
myImageView.image=[self loadImage:@"BorderedImage.jpg"];
它做什麼,如果圖像縮小,圖像變得更小,如果圖像放大,圖像變得太大。如果圖像旋轉,則圖像顯示的旋轉完全錯誤。
我知道這是某種UIImageView問題,因爲我檢查了文檔文件夾中的圖像,它就像我按下應用按鈕時一樣。
我是iOS開發新手。請幫助我。