Reputation: 21
After I select an image in the photo gallery it does not show up in the view on another screen. Any ideas?? This is the prepareforsegue. I don't know if there is a problem in this part or maybe.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"InfoSegue"]) {
UITabBarController* tabBar = segue.destinationViewController;
InstructionsViewController* instructions = [tabBar.viewControllers[0]
viewControllers][0];
instructions.delegate = self;
SettingsViewController* settings = [tabBar.viewControllers[1] viewControllers][0];
settings.delegate = self;
MoreViewController* more = [tabBar.viewControllers[2] viewControllers][0];
more.delegate = self;
UINavigationController* navSubscription = [[UIStoryboard storyboardWithName:STORYBOARD_FILE_NAME bundle:nil] instantiateViewControllerWithIdentifier:@"SubscriptionStoryboardID"];
SubscriptionViewController* subscription = navSubscription.viewControllers[0];
subscription.delegate = self;
NSMutableArray* viewControllers = [tabBar.viewControllers mutableCopy];
[viewControllers insertObject:navSubscription atIndex:viewControllers.count - 1];
tabBar.viewControllers = viewControllers;
} else if ([segue.identifier isEqualToString:@"EditorScreenSegue"]) {
[DesignController startDesign:_selectedDesign];
EditorViewController* editor = segue.destinationViewController;
editor.delegate = self;
}
else if ([segue.identifier isEqualToString:@"MyDesignsSegue"]) {
MyDesignsViewController* designs = segue.destinationViewController;
designs.delegate = self;
}
}
Upvotes: 1
Views: 47
Reputation: 14118
else if ([segue.identifier isEqualToString:@"EditorScreenSegue"]) {
[DesignController startDesign:_selectedDesign];
EditorViewController* editor = segue.destinationViewController;
editor.delegate = self;
// Use this code
editor.selectedImage = currentImage;
// selectedImage = its a UIImage property in EditorViewController.h
// currentImage = its a UIImage reference for current view controller selected image object
}
Find the added lines here in else if block. You are not passing UIImage object then how would it get displayed. As shown in code, in next view, you should use selectedImage reference in code.
Hope this will give you a hint, what you are missing.
Upvotes: 1
Reputation: 21
Don't know if this has an issue.
- (void)openImagePickerForSource:(UIImagePickerControllerSourceType)source button:
(UIButton*)button
{
if (![UIImagePickerController isSourceTypeAvailable:source]) {
return;
}
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = source;
picker.delegate = self
This part is the UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
[_popover dismissPopoverAnimated:YES];
_popover = nil;
} else {
[self dismissViewControllerAnimated:YES completion:nil];
}
UIImage* image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// Start the Image Editor Screen
[self startedDesignWithOriginalImage:image];
}
and this is the EditorViewControllerDelegate.
- (Design *)designForEditor:(EditorViewController *)editor
{
return _selectedDesign;
}
- (UIImage *)backgroundImageForEditor:(EditorViewController *)editor
{
return _selectedBackgroundImage;
}
Upvotes: 0