我有一个应用程序显示相机图片,顶部有一个按钮。 此按钮应关闭摄像机视图并转到第二个视图,但它不会。 它会重新启动相机,并保持在第一个视图上。 你能看看我做错了吗?
可在此处找到示例项目:http://wtrns.fr/P4oekRGDMncWLq
在.h
#import <UIKit/UIKit.h>
#define CAMERA_TRANSFORM_X 1
#define CAMERA_TRANSFORM_Y 1.12412
#define SCREEN_WIDTH 320
#define SCREEN_HEIGTH 480
@interface ViewController : UIViewController{
UIView *overlayView;}
-(IBAction)tosecondview:(id)sender;
@property (nonatomic, retain) IBOutlet UIView *overlayView;
@end
<。> <。>
@implementation ViewController
@synthesize overlayView;
-(IBAction)tosecondview:(id)sender{
[self dismissModalViewControllerAnimated:NO];
SecondViewController * mysecondViewController = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
[mysecondViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:mysecondViewController animated:YES];
}
....
- (void) viewDidAppear:(BOOL)animated {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
picker.cameraOverlayView = overlayView;
[self presentModalViewController:picker animated:NO];
[super viewDidAppear:YES];
}
答案 0 :(得分:0)
试试这个
[picker dismissModalViewControllerAnimated:NO];
而不是
[self dismissModalViewControllerAnimated:NO];