如何在iphone编程中导航视图?

时间:2011-08-11 07:40:51

标签: iphone

在我的appController的ViewDidLoad中,我做了一些事情,如下所示

  - (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];
}
}

我有以下两种方法,

- (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];
}
}

现在当我点击按钮时,该方法将启动显示自定义视图的类,我想在不点击按钮的情况下调用它,我该怎么办?

我直接在ViewDidLoad中编写了按钮编码,但根本没有工作

这段代码,我以苹果的文档为例

帮助!

1 个答案:

答案 0 :(得分:2)

如果我理解正确,你想要展示一个观点?

如果是这样,你可以使用:

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

或者您可以使用以下方式呈现:

[self presentModalViewControllerpushviewcontroller:YOURVIEWCONTROLLER animated:YES];