react-native-camera/RCTCamera.m

62 lines
1.2 KiB
Mathematica
Raw Normal View History

#import "RCTBridge.h"
2015-04-01 01:02:57 +00:00
#import "RCTCamera.h"
#import "RCTCameraManager.h"
2015-04-01 01:02:57 +00:00
#import "RCTLog.h"
#import "ViewfinderView.h"
#import <AVFoundation/AVFoundation.h>
@implementation RCTCamera
- (void)setAspect:(NSString *)aspect
2015-04-01 01:02:57 +00:00
{
2015-04-03 03:05:28 +00:00
[(AVCaptureVideoPreviewLayer *)[[self viewfinder] layer] setVideoGravity:aspect];
}
- (void)setCamera:(NSInteger)camera
{
2015-04-03 03:05:28 +00:00
[[self cameraManager] setCamera:camera];
}
- (void)setOrientation:(NSInteger)orientation
{
2015-04-03 03:05:28 +00:00
[[self cameraManager] setOrientation:orientation];
2015-04-01 01:02:57 +00:00
}
- (id)init
{
if ((self = [super init])) {
[self setCameraManager:[RCTCameraManager sharedManager]];
2015-04-03 03:05:28 +00:00
[self setViewfinder:[[ViewfinderView alloc] init]];
2015-04-01 01:02:57 +00:00
2015-04-03 03:05:28 +00:00
[[self viewfinder] setSession:[[self cameraManager] session]];
[self addSubview:[self viewfinder]];
2015-04-01 01:02:57 +00:00
}
return self;
}
- (NSArray *)reactSubviews
{
2015-04-03 03:05:28 +00:00
NSArray *subviews = @[[self viewfinder]];
2015-04-01 01:02:57 +00:00
return subviews;
}
- (void)layoutSubviews
{
[super layoutSubviews];
2015-04-03 03:05:28 +00:00
[[self viewfinder] setFrame:[self bounds]];
2015-04-01 01:02:57 +00:00
}
- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
{
2015-04-03 03:05:28 +00:00
[[self viewfinder] insertSubview:view atIndex:atIndex + 1];
2015-04-01 01:02:57 +00:00
return;
}
- (void)removeReactSubview:(UIView *)subview
{
[subview removeFromSuperview];
2015-04-01 01:02:57 +00:00
return;
}
@end