【问题标题】:Why is my subview not showing on top of the stack?为什么我的子视图没有显示在堆栈顶部?
【发布时间】:2017-11-03 02:31:30
【问题描述】:

我正在尝试在我的 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");
}

【问题讨论】:

  • 如何在初始化self.capture之前为self.capture设置delegate? ;)
  • BLEH 这就是我通宵工作得到的!!!!!!!当你按照正确的顺序做事时,现在睡觉就像一种魅力
  • 我可以为您的问题添加答案吗? ;)
  • 我当然马上接受
  • 恭喜你,晚安;)

标签: ios objective-c addsubview


【解决方案1】:

好像你在初始化self.capture之前为self.capture设置了delegate。初始化self.capture后尝试设置delegate

【讨论】:

  • 我认为你的意思是在 INIT 之后,但不是在 INIT 之前
  • @MattDouhan 我的错误,我已经更新了我的答案。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-15
  • 2020-10-21
  • 2013-03-13
  • 2021-05-20
相关资源
最近更新 更多