将子视图推送和弹出到堆栈时出现问题
Problems pushing and popping subViews onto the stack
我正在尝试添加一个需要显示在堆栈顶部的子层 (UINaviationController),它显示得很好,但当我尝试关闭视图时,我无法让它正常工作,它要么关闭整个 UINavigtioncontroller 并杀死整个堆栈,或者它只是删除我的部分视图并在顶部留下黑屏。
我需要的是让我的子视图显示在堆栈顶部,并能够在我的委托被调用后将其从堆栈中弹出
代码如下
在此处创建子视图
- (IBAction)transactionListViewCameraBtn_Pressed:(id)sender {
if([NWTillHelper isDebug] == 1) {
NSLog(@"%s entered", __PRETTY_FUNCTION__);
}
self.capture = [[ZXCapture alloc] init];
self.capture.camera = self.capture.back;
self.capture.focusMode = AVCaptureFocusModeContinuousAutoFocus;
[self.view.layer addSublayer:self.capture.layer];
[self.view bringSubviewToFront:self.scanRectView];
[self.view bringSubviewToFront:self.decodedLabel];
self.capture.delegate = self;
[self applyOrientation];
}
这就是我试图再次关闭子视图的方法,但是 none 它们有效
[self.view removeFromSuperview];
//[self dismissViewControllerAnimated:YES completion:nil];
//[[self navigationController] popViewControllerAnimated:YES];
//[self removeFromParentViewController];
我一定是遗漏了什么,但是什么?
您需要移除捕获层并隐藏 scanRectView
。
试试下面的代码:
self.scanRectView.hidden = YES;
[self.capture.layer removeFromSuperlayer];
我正在尝试添加一个需要显示在堆栈顶部的子层 (UINaviationController),它显示得很好,但当我尝试关闭视图时,我无法让它正常工作,它要么关闭整个 UINavigtioncontroller 并杀死整个堆栈,或者它只是删除我的部分视图并在顶部留下黑屏。
我需要的是让我的子视图显示在堆栈顶部,并能够在我的委托被调用后将其从堆栈中弹出
代码如下
在此处创建子视图
- (IBAction)transactionListViewCameraBtn_Pressed:(id)sender {
if([NWTillHelper isDebug] == 1) {
NSLog(@"%s entered", __PRETTY_FUNCTION__);
}
self.capture = [[ZXCapture alloc] init];
self.capture.camera = self.capture.back;
self.capture.focusMode = AVCaptureFocusModeContinuousAutoFocus;
[self.view.layer addSublayer:self.capture.layer];
[self.view bringSubviewToFront:self.scanRectView];
[self.view bringSubviewToFront:self.decodedLabel];
self.capture.delegate = self;
[self applyOrientation];
}
这就是我试图再次关闭子视图的方法,但是 none 它们有效
[self.view removeFromSuperview];
//[self dismissViewControllerAnimated:YES completion:nil];
//[[self navigationController] popViewControllerAnimated:YES];
//[self removeFromParentViewController];
我一定是遗漏了什么,但是什么?
您需要移除捕获层并隐藏 scanRectView
。
试试下面的代码:
self.scanRectView.hidden = YES;
[self.capture.layer removeFromSuperlayer];