내가 애플에서 제공하는이 예제 응용 프로그램의 모든 기능이 AVCam라는 복사하려고 객체 : https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112-Intro-DontLinkElementID_2필요가
내가 크기를 변화에 문제가하고있는 유일한 방법 및 UIView 개체의 위치. 문제는 사과의 샘플 코드를 사용하고 있으며 나에게 의미가 없다는 것입니다.
Apple은 MediaCapturePreviewView라는이 샘플 VC를 제공합니다. 여기에 헤더 파일의 코드는 다음과 같습니다
#import <UIKit/UIKit.h>
@class AVCaptureSession;
@interface MediaCapturePreviewView : UIView
@property (nonatomic) AVCaptureSession *session;
@end
은 기본 파일 코드입니다입니다 :
#import "MediaCapturePreviewView.h"
#import <AVFoundation/AVFoundation.h>
@implementation MediaCapturePreviewView
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
+ (Class)layerClass
{
return [AVCaptureVideoPreviewLayer class];
}
- (AVCaptureSession *)session
{
return [(AVCaptureVideoPreviewLayer *)[self layer] session];
}
- (void)setSession:(AVCaptureSession *)session
{
[(AVCaptureVideoPreviewLayer *)[self layer] setSession:session];
}
@end
그런 다음 내 응용 프로그램의 중앙보기 컨트롤러에, 난 그냥 보여 주었다 "MediaCapturePreviewView"의 헤더 파일을 가져온 당신. 마지막으로, 내 중앙 뷰 컨트롤러의 주요 파일에 나는이처럼 보이는 인터페이스 영역에 함께 IBOutlet이 있습니다
함께 IBOutlet 위는 전체 아이폰을 커버 인터페이스 빌더에서 UIView의 객체에 연결되어@property (nonatomic, weak) IBOutlet MediaCapturePreviewView *previewView;
화면. 여기에
그리고는 previewView 당신이 "사진을 찍을"버튼을 누를 때 사용되는 방법의 작은 예입니다
- (IBAction)snapStillImage:(id)sender
{
dispatch_async([self sessionQueue], ^{
// Update the orientation on the still image output video connection before capturing.
[[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]];
내가 바로 위의 메소드 호출 후에이 코드를 추가하는 시도를하지만입니다
_previewView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.frame.size.height/2);
난 당신이 프레임, 경계, 위치 등의 CALayer 클래스 개체에 대한 속성을 편집 할 수 있다는 것을 알고 있지만 난 그냥 붙어 정확히 내가이 일을 편집 할 필요가 어디 있는지 알고하지 않습니다 도움이되지 않습니다.
그리고 이것이 내가 같이 할 필요 것입니다 : 나는 기본적으로 필요
이
현재 UIView의 사진을 찍을 때 모습입니다 아이폰의 스크린의 상위 50 %를 차지한다.어떤 도움을 주셔서 감사합니다.
의 중복 가능성 ([인터페이스 빌더에서 UIView의 객체의 크기 응용 프로그램을 사용하는 경우 변경] http://stackoverflow.com/questions/21848492/size이 같은 절반 크기로 전체 화면 이미지를 캡처 응용 프로그램을 사용할 때 인터페이스 작성자가 변경하는 UI 객체) –