我工作的一個攝像頭應用,在那裏我應該表現出內設置cameraViewTransform動態地爲iOS 8
相機我使用camView.cameraViewTransform = CGAffineTransformMakeScale(1.0, 1.0) ;
,但得到了不同的設備和標籤欄之間的黑條不同的結果相機。如果我更改scaling
的值,則相機太放大。在這個問題上的任何幫助將不勝感激。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self prepareCamera];
}
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:NO];
[self launchCamera];
}
- (void)prepareCamera{
camView = [[UIImagePickerController alloc] init];
camView.delegate = self;
camView.sourceType = UIImagePickerControllerSourceTypeCamera;
camView.showsCameraControls = NO;
[self resizeCameraView];
}
- (void)resizeCameraView{
CGSize screenSize = self.view.bounds.size;
// set the aspect ratio of the camera
float heightRatio = 4.0f/3.0f;
// calculate the height of the camera based on the screen width
float cameraHeight = screenSize.width * heightRatio;
// calculate the ratio that the camera height needs to be scaled by
float scale = screenSize.height/cameraHeight;
// move the controller to the center of the screen
camView.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenSize.height - cameraHeight)/2.0);
// concatenate the scale transform
camView.cameraViewTransform = CGAffineTransformScale(camView.cameraViewTransform, scale, scale);
}
- (void)launchCamera{
[camSubView addSubview:camView.view];
[camView viewWillAppear:YES];
[camView viewDidAppear:YES];
}
你可以發佈一些代碼如何設置camView視圖? – Istvan
@Istvan感謝您的查詢,我更新了源代碼。 –