ios - Re load UIImage after game restarts -


I have a game that uses the photo library, you take a picture from the library, and then on the next screen And photos are there you play this game, and after that when you have an option to start the game again, everything is working on this point when the problem starts again, The picture does not reload. I have searched for a solution completely, but I have not got anything to help me.

So basically I have a need of a game to save the picture so that the user can continue playing with that picture. After they start resume again. Does anyone have any idea how can I get it?

Note: If the photo decides to choose a different picture, then the photo can be overwritten, as long as the new picture is saved. > Thanks for your time

edit

This is in my menu view controller

  - (minus) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {self.myImage = [information objectForKey: UIImagePickerControllerEditedImage]; [Self shotgun viewer unpowered: yes complete: zero]; [Self display CJU with identifier: @ "game" sender: self]; [Self defense]; } - (zero) save {NSDT * pngData = UIImagePNG report (myImage); NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, yes); NSString * documentsPath = [path objectAtIndex: 0]; // Get Docs Directory NSString * filePath = [Document Path StringBackCancyPantCompanyant: @ "Image Page"] ;; // Add file name [pngData writeToFile: filepath atom: yes]; // file type}   

then load the image for in my ViewController (in <)> ViewDidLoad {NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory , NSUserDomainMask, YES); NSString * documentsPath = [paths objectAtIndex: 0]; // Get the docs directory NSString * filePath = [documentsPath stringByAppendingPathComponent: @ "image.png"]; NSData * pngData = [NSData dataWithContentsOfFile: filePath]; UIImage * image = [UIImage imageWithData: pngData]; [handset Setijhejh image];}

and my Resume button

  - (IBAction) Refresh TheGame {UIStoryboard * storyboard = self.storyboard; ViewController * svc = [storyboard institute Drishykantrolr Vithaidentifayr: @ "Jimel"]; SVC. Model Tronjisnstail = Umodl Tronsisnstail Cross Disilv [own current model Viaiuai controller SCC animated: YES]; [self-loading side image];} - (void) LoadSavedImage {NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, Yes); NSString * documentsPath = [path objectAtIndex: 0]; // Get Docs Directory NSString * filePath = [Document Path StringBackCancyPantCompanyant: @ "Image Page"] ;; NSDTA * pngData = [NSData data content content file: filespath]; UIImage * image = [UIImage imageWithData: pngData]; [Copper set image: image]; }    

You can save data from when user selects the photo UIImage to file with a known file name, and just load it the next time the game restarts. To save a UIImage to the file:

  NSArray * path = NSSearchPathForDirectoriesInDomains (NSD Document Directory, NSUserDomainMask, Yes); NSString * filePath = [[Path ObjectEndIndex: 0] stringbapping pathcompany: @ "GameImage page"]; [UIImagePNG report (image) Write: Filepath atomically: Yes];   

and to reload it:

  NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, Yes); NSString * filePath = [[Path ObjectEndIndex: 0] stringbapping pathcompany: @ "GameImage page"]; NSDTa * ImageData = [NSDTATA DataWithTransffiles: Phylax]; UIImage * img = [UIImage imageWithData: imageData];   

Alternatively, you can store UIImage outside of your game data, so that you can load it the next time without hitting the file system.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -