如何更改表单工作模式视图控制器的位置?
默认情况下,它位于屏幕的中心,我想偏移表单位置,以便当我显示键盘时,它不会与表单工作窗口重叠.
这可能吗?
我疯狂地想要在我的项目中呈现和解散AVCaptureSession(在视图控制器中).我目前在iOS5.1上并启用了ARC.
我第一次出现viewcontroller并开始会话时可以正常工作但是当我解雇并再次出现时会话将无法启动.我订阅了"AVCaptureSessionRuntimeErrorNotification"通知并收到以下错误:
"错误域= AVFoundationErrorDomain代码= -11819"无法完成操作"UserInfo = 0x1a4020 {NSLocalizedRecoverySuggestion =稍后再试.,NSLocalizedDescription =无法完成操作}"
我假设在我的会话中没有正确发布某些内容,但是ARC没有发布,而是我将所有内容都设置为nil.
我的viewDidLoad方法基本上只是触发initCamera
initCamera方法:
AVCaptureSession *tmpSession = [[AVCaptureSession alloc] init];
session = tmpSession;
session.sessionPreset = AVCaptureSessionPresetMedium;
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
[self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];
rearCamera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
input = [AVCaptureDeviceInput deviceInputWithDevice:rearCamera error:&error];
if (!input) {
// Handle the error appropriately.
NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];
videoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey, …Run Code Online (Sandbox Code Playgroud) modalviewcontroller ios avcapturesession automatic-ref-counting
这似乎是整个Apples应用程序中使用的模式; 通过模态视图创建新记录,需要保存或取消以继续,并且通过推入导航堆栈的视图来编辑记录.
基本上将我的ViewController复制为"添加"和"编辑"似乎并不正确,但推送和模态ViewControllers的工作方式有很多不同之处.
我应该怎么做才能覆盖两个基地?
-
差异包括.
当推入堆栈时,导航栏出现在视图的顶部,可以配置为包含取消/保存按钮.当以模态方式呈现时,情况并非如此,因此复制界面需要单独创建工具栏并关闭/保存添加到此的按钮.
当解除推送视图时,我们向导航控制器发送消息[self.navigationController popViewControllerAnimated:YES];,当解除模态视图时,我们向自己发送消息[self dismissModalViewControllerAnimated:YES];
如何在显示模态时从模态segue中删除过渡效果,如下所示:
[self performSegueWithIdentifier:@"SomeIdentifier" sender:self];
Run Code Online (Sandbox Code Playgroud)
我知道我可以进入故事板并在4种不同的动画之间切换,但我不想要任何动画!我该如何删除它们?
我知道我可以说,presentModalViewController animated: NO但我没有,也不能这样称呼它.我需要使用该performSegueWithIdentifier方法.
所以我在Xcode中使用"Utility Application"模板并拥有主视图控制器,用户可以使用按钮隐藏和显示状态栏.我还有一个Flipside View控制器,使用模态segue,它有一个完成按钮返回到主VC.我已将其设置为每次查看Flipside VC时,状态栏始终不会被隐藏.这意味着如果用户隐藏主VC上的状态栏并转换到Flipside VC,它将动画显示,如果用户没有隐藏状态栏并且他们转换,则状态栏没有任何反应.
这一切都很好,问题是从转变回到贫乏VC到主VC.我需要一个条件来检查主VC中状态栏的隐藏状态,当按下完成按钮时,它将在Flipside VC中调用.
我已经研究过使用BOOL和NSNotificationCenter向Flipside VC发送有关状态栏状态的消息.
我有这个代码:
-(BOOL)checkStatusBarHidden:(id)input
{
BOOL result;
if ([UIApplication sharedApplication].statusBarHidden = YES)
{
result = YES;
}
else
{
result = NO;
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
但这只是猜测和思考我可以在某处使用它来通知Flipside VC状态栏状态.我想到也许改变了
[UIApplication sharedApplication].statusBarHidden = YES)
Run Code Online (Sandbox Code Playgroud)
喜欢的东西
self.statusBarHidden = YES //which of course isn't going to work
Run Code Online (Sandbox Code Playgroud)
但无论如何,正如我所说,这是在猜测,我不知道该怎么做.
将帐户添加到Mail(在首选项中)时,您将获得模态视图,如下所示:

我的问题是,我如何以编程方式复制这个?换句话说,如何在呈现视图上显示模态UIView?
这就是我所拥有的:
import UIKit
class ViewController: UIViewController {
@IBAction func addCard(sender: AnyObject) {
var addContact : secondViewController = secondViewController()
self.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal
self.modalPresentationStyle = .CurrentContext // Display on top of current UIView
self.presentViewController(addContact, animated: true, completion: nil)
}
//Code goes on to do other unrelated things
Run Code Online (Sandbox Code Playgroud)
另外,我做了以下事情:
预期的行为是,当按下UIBarButton"Add Contact"(@IBAction func addCard(sender: AnyObject)在上面的代码中成功触发 )时,secondViewController将呈现为主视图上方的模态视图.
当我运行上面的代码时,我收到错误 "Use of undeclared type secondViewController"
我究竟做错了什么?
注意:这是对早期问题的重新提问,其中我问了一个类似但略有不同的问题.我检查了meta,我认为它没关系 - 我不想让原始问题的答案无效,因为这是在问一些稍微不同的东西.另外,如果它有帮助,我发现了一些类似的问题 - …
是否可以在呈现模型视图控制器的同时与呈现视图控制器进行交互?
------------
| |
| VC1 |
| |
| |
| |
| |
|------------|
| VC2 |
| |
------------
Run Code Online (Sandbox Code Playgroud)
在上图中,VC1 是presentingViewController,VC2 是presentedViewController。我试图实现的用户体验是用户可以与 VC1 和 VC2 进行交互。目前,当呈现 VC2 时,触摸不会传递到 VC1。
objective-c uiviewcontroller modalviewcontroller presentmodalviewcontroller ios
我正在尝试实现类似于 iOS 版 Netflix 应用程序的导航。当您单击电影时,会弹出一个带有关闭按钮的模式窗口。如果在这部电影中我选择观看另一部电影,则会弹出第二个模式,除了关闭按钮之外,还会出现后退按钮。我可以使用后退按钮一一关闭,并使用关闭按钮返回到基本屏幕。
我可以使用消除单个视图
dismiss(animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
但我怎样才能返回到基本屏幕并立即关闭所有模式呢?另外,模态是要走的路吗?我选择这个是因为我不希望导航栏位于顶部。
我正在 Xcode 10 中使用 Swift 4.2。
我在以模式方式使用视图控制器作为登录页面时遇到问题。我可以让控制器出现,但无法更改其全尺寸。
我试图在屏幕中央呈现带有褪色背景的弹出框。当我在视图之外单击时,弹出窗口应该关闭。
我浏览了整个网站的问题和答案,但没有找到对我有用的问题和答案。
这是我的代码:
import UIKit
class SignInView: UIViewController, UIPopoverPresentationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "popoverSegue" {
var popover = segue.destination as! SignInPopView
popover.popoverPresentationController!.delegate = self
popover.modalPresentationStyle = UIModalPresentationStyle.popover
popover.preferredContentSize = CGSize(width: 375, height: 500)
}
}
Run Code Online (Sandbox Code Playgroud) TLDR:寻找一种解决方案,以在从导航栏向下拖动时启用交互式关闭,而不是从视图控制器的视图中拖动。
iOS 13 模态视图控制器允许通过以下几种方式禁用交互式关闭:
vc.modalPresentationStyle = .fullScreen(请参阅在 iOS 13 全屏显示模式)viewController.isModalInPresentation = true(请参阅禁用 iOS 13 中呈现的视图控制器的交互式关闭)UIAdaptivePresentationControllerDelegate委托方法(请参阅iOS13 中的 UINavigationBar 更改)如果您想要与 iOS 12 及更低版本相同的行为,第一个很棒。
第二个,非常适合防止交互式关闭,但仍然允许在从主视图控制器视图中拉动时向下拖动视图控制器(带有漂亮的动画)。
后者允许更好地处理事件,但无助于防止从视图控制器的视图中拖动。
我见过的最接近的事情是设置刷新控件以防止在下拉刷新期间被关闭。此 GIF 显示了我正在寻找的行为(来源):
这种下拉刷新交互可以在 iOS 日历应用程序的模式收件箱屏幕中看到。
我正在寻找的行为与上面的下拉刷新相同,但没有滚动视图和刷新控件。
基本上,对视图控制器视图的触摸不应触发交互式解除。
我尝试了以下方法,但没有运气:
view.isExclusiveTouch = trueview.isUserInteractionEnabled = false总之,我需要的是:
谢谢!