Search code examples
iphoneuitabbarcontrollermodal-dialoguitabbarviewdidload

iPhone tabBar - How should I implement a Modal view so that each time a tab is selected it appears?


Could you tell me the best way to implement a Modal view so that it appears each time a certain tab is selected/pushed? Because the way I currently have my code results in all subsequent selections/pushes doing nothing.

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
    UIImage *image;
    IBOutlet UIImageView *imageView;
}

@end

#import "SecondViewController.h"

@implementation SecondViewController

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    image = [info objectForKey:UIImagePickerControllerOriginalImage];
    imageView.image = image;
    [self dismissModalViewControllerAnimated:YES];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

...
@end

Solution

  • You might check out

    -(void)viewWillAppear {}