4

iPhone で QR コードを読み取るためにZBar SDKを使用していますが、カメラ/スキャナー ビューの下部に、ユーザー向けの説明テキストであるテキストを追加したいと考えています。これが私がこれまでに持っているものです:

UIView *cameraOverlayView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    cameraOverlayView.backgroundColor = [UIColor redColor];

    UILabel *instructionLabel = [[UILabel alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    [instructionLabel setTextColor:[UIColor grayColor]];
    [instructionLabel setBackgroundColor:[UIColor clearColor]];
    [instructionLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 24.0f]];
    [instructionLabel setCenter:cameraOverlayView.center];
    [cameraOverlayView addSubview:instructionLabel];

    reader.cameraOverlayView = cameraOverlayView;
    reader.wantsFullScreenLayout = YES;

    [instructionLabel release];
    [cameraOverlayView release];

完全なクラスは次のとおりです。

https://gist.github.com/4163761

残念ながら、ラベルは表示されません。ZBar のドキュメントには、この目的で cameraOverlayView を使用するように記載されていますが、機能していないようです。

もう1つ注意してください。私はTitaniumフレームワークを使用しているため、追加のTitaniumクラスはそこからのものですが、私の質問はZBarに固有のものでなければなりません。

4

1 に答える 1

6

cameraOverlayView が表示されますか? 背景色を赤か何かに設定します: cameraOverlayView.backgroundColor = [UIColor redColor];

cameraOverlayView がまったく表示されない場合は、おそらくリーダーを設定する必要があります。showsZBarControls = NO を指定すると、デフォルト コントロールが無効になり、カスタム オーバーレイが使用されます。

cameraOverlayView が表示される場合は、ラベルが境界外にある可能性があります。原点をいじって、位置を合わせます。

ところで、あなたは ARC を使用していないようです。instructionLabel を必ずリリースしてください。

于 2012-11-29T00:24:00.063 に答える