小编spa*_*h21的帖子

ios AVFoundation点击即可关注

我正在尝试创建一个相机应用程序,它或多或少会像默认的相机应用程序.目前对我不起作用的东西是重点关注.我希望相机能够对焦并在触摸点上做任何事情,就像真正的相机应用程序一样.

这是我的viewDidLoad

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Session
    _session = [[AVCaptureSession alloc] init];
    _session.sessionPreset = AVCaptureSessionPresetPhoto;

    // Input
    _videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    _videoInput = [AVCaptureDeviceInput deviceInputWithDevice:_videoDevice error:nil];

    // Output
    _frameOutput = [[AVCaptureVideoDataOutput alloc] init];
    _frameOutput.videoSettings = [NSDictionary dictionaryWithObject:AVVideoCodecJPEG forKey:AVVideoCodecKey];

    [_frameOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
    [_session addInput:_videoInput];
    [_session addOutput:_frameOutput];
    [_session startRunning];
};
Run Code Online (Sandbox Code Playgroud)

这里的方法应该让我的相机专注于点击.

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    [touches enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
        UITouch *touch = obj;
        CGPoint touchPoint = [touch locationInView:touch.view];
        focusLayer.frame = CGRectMake((touchPoint.x-25), (touchPoint.y-25), 50, 50);

        if ([_videoDevice isFocusPointOfInterestSupported]) …
Run Code Online (Sandbox Code Playgroud)

camera avfoundation ios

25
推荐指数
2
解决办法
2万
查看次数

SKAction完井处理程序; 在Swift中的用法

我是Swift和SpriteKit的新手.很多SpriteKit动作的样本都在Objective C中,我无法在Swift中映射,也无法工作.

如果运行SKAction,并且在SKAction完成后想要做其他事情,我如何在Swift中做到这一点?

    spaceMan.runAction(spaceManDeathAnimation, completion: {
        println("red box has faded out")
    })
Run Code Online (Sandbox Code Playgroud)

任何想法将不胜感激.

编辑:

for i in 0...29 {
    textures.append(SKTexture(imageNamed: "spaceManDeath_\(i)"))
}
spaceManDeathAnimation = SKAction.repeatActionForever(SKAction.animateWithTextures(textures, timePerFrame: 0.15625))
Run Code Online (Sandbox Code Playgroud)

handler sprite-kit skaction swift completion

11
推荐指数
2
解决办法
7770
查看次数

快门动画AVFoundation iphone

我正在尝试复制iPhone Camera应用程序的默认快门动画.

也许有人试过这样做并有一些提示要分享?

camera ios

6
推荐指数
1
解决办法
3222
查看次数

iOS - 为圆圈设置虚线

CAShapeLayer *circle = [CAShapeLayer layer];

circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath;

// Configure the apperence of the circle
circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor whiteColor].CGColor;
circle.lineWidth = 1;      
// Add to parent layer
[[background layer] addSublayer:circle];
Run Code Online (Sandbox Code Playgroud)

我画了一个圆圈并将其添加为子图层.我不明白的是如何使圆线虚线?我在上面添加了我的圈子代码.

line ios

5
推荐指数
1
解决办法
4424
查看次数

Swift选择器 - 发送到实例的无法识别的选择器

我有一个功能:

func runRockRotation(rockSprite: SKSpriteNode){
    startRockRotationAnimation(rockSprite, isRock: true)
}
Run Code Online (Sandbox Code Playgroud)

当我这样称呼时:

runRockRotation(rock)
Run Code Online (Sandbox Code Playgroud)

它工作,但我似乎无法将其放入NSTimer选择器.

var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "runRockRotation:", userInfo: rock, repeats: false)
Run Code Online (Sandbox Code Playgroud)

阅读了很多论坛,试过这个:

var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "runRockRotation()", userInfo: rock, repeats: false)
var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "runRockRotation(_)", userInfo: rock, repeats: false)
var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "runRockRotation", userInfo: rock, repeats: false)
Run Code Online (Sandbox Code Playgroud)

此外,尝试没有摇滚,使用零,但似乎没有任何工作.

每次我得到:

2015-04-10 15:49:03.830 Meh[1640:218030] -[__NSCFTimer runAction:completion:]: unrecognized selector sent to instance 0x174166840
2015-04-10 15:49:03.832 Meh[1640:218030] *** Terminating app due …
Run Code Online (Sandbox Code Playgroud)

selector nstimer ios swift

5
推荐指数
1
解决办法
2394
查看次数

Xcode 8和"ld:找不到-lcrypto的库"

当我尝试构建我的项目时,我遇到了以下问题.

ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

在最新的Xcode更新之前,我通过CocoaPods使用OpenSSL就好了.在最新的OS和Xcode更新之后,我似乎无法构建OpenSSL.

任何想法如何解决这个问题?在Xcode 7上一切正常.

macos xcode openssl objective-c xcode8

5
推荐指数
1
解决办法
3826
查看次数

NSCollectionView,Swift 4 - 无法调用"注册"

任何人都可以建议如何解决这个NSCollectionView问题?从Swift 3转换为Swift 4并且魔术开始发生:)

码:

let item = NSNib(nibNamed: NSNib.Name(rawValue: "MACollectionViewItem"), bundle: nil)
collectionView.register(item, forItemWithIdentifier: "CollectionViewItem")
Run Code Online (Sandbox Code Playgroud)

第二行错误:

无法register使用类型的参数列表调用' ''(NSNib?, forItemWithIdentifier: String)'

nscollectionview nscollectionviewitem swift swift3 swift4

3
推荐指数
1
解决办法
1925
查看次数