- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我得到了一个使用 SplitViewController
的 iPad 设计的应用程序,该应用程序显示两个 View ,一个带有联系人列表,另一个带有此联系人的详细信息。 SplitView
在 iPad 上运行良好,但在 iPhone 上存在一些问题。
有一个 UIControl 占用主视图的所有大小,检查用户是否有任何 .touchDown 交互
以及调用一些方法来启用或禁用此 UIControl
取决于我们是在编辑联系人模式还是不允许用户与屏幕交互:
private var disableInteractionClosure: (()->())?
private lazy var interactionOverlay: UIControl = {
let c = UIControl()
c.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
c.addTarget(self, action: "interactionOverlayAction", forControlEvents: .TouchDown)
return c
}()
func disableInteractionWhileEditingWithClosure(callback: ()->()) {
if disableInteractionClosure == nil {
disableInteractionClosure = callback
/* display control overlay */
interactionOverlay.frame = navigationController!.view.bounds
navigationController!.view.addSubview(interactionOverlay)
}
}
func interactionOverlayAction() {
disableInteractionClosure!()
}
func enableInteraction() {
disableInteractionClosure = nil
interactionOverlay.removeFromSuperview()
}
基本上,UIControl
用于阻止用户在编辑另一个联系人时在联系人之间切换/通过阻止与联系人列表的交互来创建新联系人,如果更改已经在编辑/创建 View 上进行了它触发一个方法,显示一个弹出窗口说“修改已经完成,你想继续而不保存吗?取消或继续”:
func cancel() {
self.view.endEditing(true)
let closure: ()->() = {
self.layoutView.willResign()
self.delegate?.tabDetailsControllerDidCancel(self)
}
if layoutView.hasChanges() {
MKAlertViewController().instantaneousAlert(title: "Modification apportées", message: "Êtes-vous sur de vouloir continuer sans sauvegarder les modifications ?", confirmButtonTitle: "Oui", cancelButtonTitle: "Annuler", confirmed: { () -> Void in
closure()
}, canceled: { () -> Void in
})
} else {
closure()
}
}
它在 iPad 上工作正常,因为 UIControl
仅在主视图上方,并且在详细 View (iPad 3D Debugging view) 的编辑模式下启用,因此弹出窗口仅在手动取消时显示编辑/创建或在编辑/创建时尝试更改联系人时,但由于 splitView
在 iPad 和 iPhone 上的工作方式不同,而且在 iPhone 上似乎主视图位于详细信息上方查看,UIControl
也在上方 ( iPhone 3D Debugging view ),它会导致阻止所有屏幕上的交互,无论我点击什么地方都会显示取消弹出窗口。
你们能否向我解释一种仅在 MasterView 显示时而不是在所有地方显示时启用/显示此 UIControl 的方法。谢谢。
最佳答案
我最终在详细 View 上使用了 viewWillDisappear
:
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
if self.isMovingFromParentViewController() || self.isBeingDismissed() {
if editingMode {
shared.contactsListController.disableInteractionWhileEditingWithClosure({ (_) in
self.tabDetailsController.cancel()
})
shared.contactsListController.disableToolbar()
} else {
shared.contactsListController.enableInteraction()
shared.contactsListController.enableToolbar()
}
self.navigationController?.toolbar.alpha = 1
}
}
并修改主视图上的 disableInteractionWhileEditingWithClosure
方法:
func disableInteractionWhileEditingWithClosure(callback: ()->()) {
if disableInteractionClosure == nil {
disableInteractionClosure = callback
/* display control overlay */
interactionOverlay.frame = navigationController!.view.bounds
view.addSubview(interactionOverlay) // this line
}
}
而且有效! :)
关于ios - UIControl 阻止了我在 iPhone 上的所有 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36127040/
我正在制作一个自定义 iOS 键盘,并有一个 UIControl 子类来表示我的按钮。我试图获得与普通 iOS 键盘相同的行为: 用户开始触摸一个按钮 用户拖动其他按钮(需要检测到这一点,以便他们可以
这是设置:我在表格单元格中有 UIControls,允许从右向左滑动以实现删除功能(如清除) 表格单元格位于 UITableView 中。 TableView 位于另一个 UIControl 中,该
我做了一些关于自旋转的实验。情况:我有一个 TabBar 4(选项卡),三个应该只是纵向。最后一个是 UINavigationController,它本身不应自动旋转任何堆叠的 Controller
我有一个名为 CheckboxView 的 UIControl 自定义子类,当用户点击矩形时,它只是在矩形内绘制一个复选标记。这是作为一个单元格添加到 tableView 中的,它位于主容器 Attr
我注意到,当控件是其他控件的子控件并且部分位于父控件边界之外时,仍然可以看到控件在父控件边界之外的部分。 例如,我将一个图像放置在一个网格内,部分放置在网格边界之外,但该图像仍然完整显示。 如何将要显
我尝试以编程方式将 UITableView 添加到 ScrollView 中。我已经设置了 anchor 和数据源,委托(delegate)。你可以在代码中看到。但我不能。我放了一个断点,一切都运行了
Documentation of UIControl Class : UIControlEventTouchDragInside、UIControlEventTouchDragEnter、UICont
我有两个自定义 UIControl。这些是滚轮。 它们的框架重叠。在屏幕截图中,左上角的那个在右边那个后面。当在重叠区域内启动触摸时,如何在左侧开始跟踪? 我的 beginTrackingWithTo
我创建了第 3 方键盘,并尝试为我的按键添加背景。我使用 UIControl 作为我的键,没有 Storyboard。 我有几种类型的按钮,并尝试为我的角色添加背景 UIView。 let img =
我正在创建 GUI,我希望在那里有输入和结果。 我有 text 字段作为标签,edit 或 popup 用于输入。当我有 uicontrol('style','text','string','foo'
我有一个 UIControl 子类。我使用以下代码更改它的背景颜色: - (void)drawRect:(CGRect)rect { [self.backgroundColor setFill
我有一个 UIControl,它实现了 touches begind 方法,如下所示: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent
我不想要 UIButton 或类似的东西。我想直接继承 UIControl 并制作我自己的非常特殊的控件。 但由于某种原因,我覆盖的任何方法都没有被调用。目标 Action 的东西有效,目标接收适当的
我的自定义子类扩展 UIControl (EditableImageView)基本上它包含 3 个 subview : UIButton(UIButtonTypeCustom) UIImageView
我目前有一个 UIControl,它有许多 subview (图像、标签)。 不幸的是,当我使用 addTarget 等时,它不会检测到 subview 上的触摸。 [myCustomView a
基本上我需要一个图像按钮,特别是一个自定义对象: 1) 点击时调用 Controller 的操作 2)封装自定义数据 3)由包装 View 自动移动(不相关) 好吧,我通过 UIControl 的子类
我可以在短时间内禁用按钮吗?我有一个注册 View ,在 3 次错误尝试时,它会将用户带到注册 View 之外,并且会在一段时间内禁用注册按钮,比如 5 分钟。是否可以? 最佳答案 - (void)
我已经构建了一个 UIControl 子类来显示 1 个月的日历 View 一部 iPhone。大多数月份需要 5 周才能显示日期,但 有些月需要 6,所以我建立了动态调整大小的控件 自己根据需要
我创建了一个名为“TestButton”的 UIControl 子类,带有标签和 imageview subview 。该对象是使用框架创建的,作为初始化过程的一部分,我创建了 subview 元素。
堆栈溢出, 我正在努力扩展 UIControl 以为其自身分配单个值。实现这一点是为了它可以在启动时分配一个值以实现持久性。我的目标是尽可能普遍地做到这一点,以便它可以轻松扩展。我的方法的主要组成部分
我是一名优秀的程序员,十分优秀!