2

クラッシュメッセージがあります:

*キャッチされない例外 'NSInvalidArgumentException' が原因でアプリを終了しています。理由: 'focusPointOfInterest の設定は、このデバイスではサポートされていません。「isFocusPointOfInterestSupported」を使用

コードの後:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [device setFocusPointOfInterest:CGPointMake(100, 100)];
}

カメラロールのようにフォーカスを合わせる方法はありますか?

4

3 に答える 3

1

答えの組み合わせですが、これはあなたを助けるはずです。

タッチ開始またはタッチ ジェスチャからのタッチ ポイントを 0 ~ 1 のスケールに変換する必要があります。

したがって、デバイスにフォーカスがあるかどうかを確認してから、ポイントを変換します。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // get device reference...

    if ([device isFocusPointOfInterestSupported]) {
        CGPoint point = [touch locationInView:self.myCameraView];
        float newX = point.x / self.myCameraView.frame.size.width;
        float newY = point.y / self.myCameraView.frame.size.height;
        [device setFocusPointOfInterest:CGPointMake(newX, newY)];
    }
    else {
        // Focus not supported
    }
}
于 2013-07-18T16:15:15.760 に答える
0

すべてのiOSデバイスがサポートしているわけではないため、使用してsetFocusPointOfInterest受け入れられるかどうかを確認する必要があります。私の記憶が正しければ、フロント/バックカメラによっても異なります[device focusPointOfInterestSupported]

于 2013-03-12T17:05:43.277 に答える
0

JoeCortoPassi が言ったこと。

したがって、基本的に if ループを実行して [device focusPointOfInterestSupported] が true を返すかどうかを確認してから、[device setFocusPointOfInterest:CGPointMake(100, 100)]; を実行します。

編集:

コードは次のようになります。

if ([device isFocusPointOfInterestSupported]){
    [device setFocusPointOfInterest:CGPointMake(100, 100)];
}else{
     // Not supported
}

お役に立てれば!

于 2013-03-12T19:36:51.683 に答える