iphone - How to use an image taken in the 1stViewController in the 2ndViewController? -


User can choose whether he wants to use an existing image or takes new to use as background is.

Everything works until the first scene controller is concerned. Unfortunately the image is no longer being set as a background, when the second VUI controller is displayed.

How do I enable the use of the image in the form of a background for the second controller?

I used this piece of code (in second view controller):

  NSUserDefaults * prefs = [NSUserDefaults standard user default]; Int BLA = [Prefix integerfori: @ "background_key"]; If (bla == 1) {self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "1.mac.jpg"]]; } And if (bla == 2) {self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "black.jpg"]] ;; } And if (bla == 3) {self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "pinn.png"]]; } And if (bla == 4) {self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "MyImage.png"]] ;; }  

I tried to save the image selected as "mice" but it seems like it does not work. The background is black rather than the selected picture.

I used this code (from 1stViewController) to save the selected photo as "MyImage.png":

  - (zero) imagePickerController: (UIImagePickerController *) Picker didFinishPickingMediaWithInfo: (NSDictionary *) anInfo {// UIImage * selectedImage; NS URL * Media URL; MediaUrl = (ns URL *) [anInfo valueForKey: UIImagePickerControllerMediaURL]; If (mediaUrl == Blue) {selectedImage = (UIImage *) [anInfo valueForKey: UIImagePickerControllerEditedImage]; If (selected image == zero) {selectedImage = (UIImage *) [anInfo valueForKey: UIImagePickerControllerOriginalImage]; NSLog (@ "Original Image Selected."); } Other {nslog (@ "edited image."); }} [Picker Dismodal Moodle Controller Permission: Yes]; If (selected image! = Zero) {self.view.backgroundColor = [UIColor colorWithPatternImage: selectedImage]; } // Get the image from the result UIImage * auto image = [anInfo value forKey: UIImagePickerControllerOriginalImage]; // Get data for image as a PNG NSDTITA * imageData = UIImagePNGRepresentation (ownImage); // Name the file NSString * imageName = @ "MyImage.png"; // Now, we have to find the document directory so that we can save it // Note that you would like to save it somewhere, such as the cache directory, // or something like that. NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, yes); NSString * document directory = [path item overindexx: 0]; // Now we can get the full path to the file NSString * fullPathToFile = [document directory stringbapaddingpacecompanent: image name]; // And then we write it [imageData writeToFile: fullPathToFile atomically: no]; Return; }  

Help should be a mistake or a logical mistake will be appreciated!

"post-text" itemprop = "text">

ImageName is usually used to load images, which are included in the form of resources as an application.

I doubt you want to:

  UIImage * image = [UIImage imageWithContentsOfFile: fileNameAndPath];  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -