In my iOS app, a user can select an image from a list, upon which they are presented with a modal that contains the image and options to delete the image. If the user chooses t
You should make a protocol in your MediaPreviewViewController. Then when the image is deleted, send a delegate method so the parent viewcontroller can handle that.
You also should never let the viewcontroller dismiss itself (though it is possible, but recommended that the view which created the modal is also responsible for removing the modal...)
So you should get something like this:
In MediaPreviewViewController.h:
@protocol MediaPreviewViewControllerDelegate
-(void)didRemovedImage;
@end
@interface MediaPreviewViewController : NSObject {
id< MediaPreviewViewControllerDelegate > delegate;
}
@property (nonatomic, assign) id < MediaPreviewViewControllerDelegate> delegate;
In MediaPreviewViewController.m:
@synthesize delegate = _delegate;
Then in your method in your MediaPreviewViewController where you remove the image, you just call:
[_delegate didRemoveImage];
In your parent viewcontroller, you need to implement this protocol like you are used to with delegates.. You then can also remove the view from the parent in this delegate method