为什么我的子视图没有显示在堆栈顶部?

时间:2017-11-03 02:31:31

标签: ios objective-c addsubview

我正在尝试在我的NavigationStack上添加一个摄像头捕获子视图,但即使代码根据调试运行正常,子视图也不会显示在顶部,所以我无法使用摄像头进行扫描

代码如下所示,为什么它不会显示在堆栈顶部?

- (IBAction)transactionListViewCameraBtn_Pressed:(id)sender {

    if([NWTillHelper isDebug] == 1) {
        NSLog(@"%s entered", __PRETTY_FUNCTION__);
    }

    NSLog(@"jongel1");
    self.capture.delegate = self;
    NSLog(@"jongel2");
    [self applyOrientation];
    NSLog(@"jongel3");
    self.capture = [[ZXCapture alloc] init];
    self.capture.camera = self.capture.back;
    self.capture.focusMode = AVCaptureFocusModeContinuousAutoFocus;
    NSLog(@"jongel4");
    [self.view.layer addSublayer:self.capture.layer];
    NSLog(@"jongel5");
    [self.view bringSubviewToFront:self.scanRectView];
    [self.view bringSubviewToFront:self.decodedLabel];
    NSLog(@"jongel6");
}

1 个答案:

答案 0 :(得分:2)

似乎在初始化delegate之前为self.capture设置了self.capture。初始化delegate后尝试设置self.capture