- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Swift 4 和 XCode 9。我正在尝试以编程方式控制我的 UITabBarController 中的导航。根据Apple's documentation ,我需要实现 UITabBarControllerDelegate
协议(protocol)。但是,我实现的方法从未被调用:
import UIKit
class TabBarController: UITabBarController, UITabBarControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
tabBarController?.delegate = self
}
func tabBarController(_ tabBarController: UITabBarController,
shouldSelect viewController: UIViewController) -> Bool {
print("Should go here...")
return true
}
}
知道我做错了什么吗?
最佳答案
您的问题是您设置了错误的委托(delegate)。将 viewDidLoad
更新为:
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self // or just "delegate = self"
}
想法是您希望此选项卡 Controller 成为它自己的委托(delegate)。
关于ios - UITabBarControllerDelegate 的 shouldSelect 方法从未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48332473/
我正在编写具有以下结构的 iPhone 应用程序(在 Storyboard中创建) UIView --> TabBarController --> 1.NavigationController -->
这是我正在尝试做的事情: 当用户单击“压缩机”按钮时,它会显示一个 ScrollView ,其中包含压缩机(或其他)的详细信息。要返回菜单,用户单击“更多”选项卡栏项。 我设置了一个变量 first
我有一个有 4 个选项卡的选项卡栏 Controller ,我想要:当点击第 4 个选项卡(虚拟 View Controller )时,它将显示一个新的 View Controller 而不显示虚拟
我有一个基于标签栏的应用程序并执行以下操作以获取对应用程序委托(delegate)的引用: MyAppDelegate *appDelegate = [[UIApplication sharedApp
每当用户触摸标签栏项目(即使它对应于当前显示的 View )时,我都需要收到一条消息。我不确定是否使用 UITabBarDelete 协议(protocol),该协议(protocol)提供: - (
我创建了一个新类来实现UITabBarControllerDelegate,但是类中的方法没有被调用。 AppDelegate.swift: func application() { // ...
我想在我的所有 viewControllers 上实现一个 scrollToTop 方法在我的UITabBarController .以下是UITabBarControllerDelegate中的一个
我正在使用 Swift 4 和 XCode 9。我正在尝试以编程方式控制我的 UITabBarController 中的导航。根据Apple's documentation ,我需要实现 UITabB
我有一个带有 4 个选项卡的 tabbarcontroller。当用户选择其中一个选项卡时,我想为新的 View Controller 做一些设置 - 即 ...[newVC.databaseid=
我有一个涉及 UITabBarControllerDelegate 的奇怪问题。 我正在使用以下代码: import UIKit class MainTabBarController: UITabBa
我有一个带有 4 个 UINavigationControllers 的 UITabBarController。我已经实现了 didSelectViewController 委托(delegate)方
我正在尝试在用户点击标签栏按钮时创建自定义标签栏动画。 我已经实现了一个实现了 UITabBarControllerDelegate 的 UITabBarController 子类 这是.m #imp
我有以下代码,我试图在 UIViewcontroller 上实现“滚动到顶部”并在另一个 UIViewController 上实现“滚动到开始”。 第一个 VC 有一个 TableView ,第二个
我正在尝试为我的 UITabBarController 中的选项卡之间的转换设置动画,当我按下选项卡按钮时它工作正常。但是,当我通过调用以编程方式切换选项卡时 [self.tabBarControll
大家好, 有人知道为什么我会收到附图中的警告吗?在相关代码的正上方是我从一本 Apress 书籍“更多 iPhone 3 开发”中获得的代码的注释。作者试图告诉我一些有关类型转换的信息以消除警告,但我
我是一名优秀的程序员,十分优秀!