Chatar Veer Suthar
Chatar Veer Suthar

Reputation: 15639

How to navigate the view in iphone programming?

In my appController's ViewDidLoad, I have done some thing as below

  - (void)viewDidLoad
 {
self.overlayViewController =
    [[[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil] autorelease];

// as a delegate we will be notified when pictures are taken and when to dismiss the image picker
self.overlayViewController.delegate = self;

self.capturedImages = [NSMutableArray array];

if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    // camera is not on this device, don't show the camera button
    NSMutableArray *toolbarItems = [NSMutableArray arrayWithCapacity:self.myToolbar.items.count];
    [toolbarItems addObjectsFromArray:self.myToolbar.items];
    [toolbarItems removeObjectAtIndex:2];
    [self.myToolbar setItems:toolbarItems animated:NO];
}
}

I have two methods as below,

- (IBAction)cameraAction:(id)sender
 {
[self showImagePicker:UIImagePickerControllerSourceTypeCamera];
}

- (void)showImagePicker:(UIImagePickerControllerSourceType)sourceType
{
if (self.imageView.isAnimating)
    self.imageView.stopAnimating;

if (self.capturedImages.count > 0)
    [self.capturedImages removeAllObjects];

if ([UIImagePickerController isSourceTypeAvailable:sourceType])
{
    [self.overlayViewController setupImagePicker:sourceType];
    [self presentModalViewController:self.overlayViewController.imagePickerController animated:YES];
}
}

Now as I click the button, the method will launch the class showing custom view, I want to call this without clicking the button, what should I do ?

I wrote the button coding directly in ViewDidLoad, but not working at all

This code, I took from apple's documentation as example

Help !

Upvotes: 0

Views: 156

Answers (1)

user456236
user456236

Reputation:

If I understand correctly, you are wanting to show a view?

If so you could push using:

[self.navigationcontroller pushviewcontroller:YOURVIEWCONTROLLER animated:YES];

Or you could present it using:

[self presentModalViewControllerpushviewcontroller:YOURVIEWCONTROLLER animated:YES];

Upvotes: 2

Related Questions