문제

I am writing an iPhone app, where the user should be able to choose, an in-app background picture from his own photo album.

I am trying to enable this feature using a UIImagePickerController.

At this point I get the the box asking me to choose a picture and I save the picture. But after that, when I want to use the image chosen as background, with this kind of code (which is the same as how I set the default background at start):

    UIColor *backGrndPict=[[UIColor alloc] initWithPatternImage:
                           [UIImage imageNamed:pngPath]];
    self.view.backgroundColor=backGrndPict;

Nothing works. I just get a white background.

Thanks for any tip.

올바른 솔루션이 없습니다

다른 팁

Michel, Just for clarification, are you saving the picture that the user selects as a .png file or in an UIImage? If you did use the UIImage method, try double checking the retain count of the UIImage. Again, it may not be as simple as this, but that is what I did with my app and was getting the exact same issue. If you did save it as a .png file, did you do an error check? Also, I have the "Applications" folder for my iOS simulator loaded on the screen perchance I have to verify both the availability and the integrity of the file in question. Also, I tend to slip on the path sometimes too. I have have messed up the path one too many times by forgetting to use the saved path (the file that my app saved, almost always under the documents folder) vs. the default bundle path for the app which is where the bundled images are saved. Hope it helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top