ios - CoocaPod:“.....”类型的值没有成员“....”,但应该有
问题描述
我正在使用这个 cocoapod来创建一个小弹出视图来重置所有存储的 UserDefaults。因此,我希望弹出窗口的“是”和“否”按钮水平对齐(默认为垂直)。这是我的代码:
resetBtn.touchUpInside{ [self] in
let dialogAppearance = PopupDialogDefaultView.appearance()
let buttonAppearance = DefaultButton.appearance()
let title = "Do you really want to reset this game?"
let popup = PopupDialog(title: title)
let yesBtn = DefaultButton(title: "Yes", height: 60) {
self.click()
defaults.removePersistentDomain(forName: Bundle.main.bundleIdentifier!)
defaults.synchronize()
}
let noBtn = DefaultButton(title: "No", height: 60) {
self.click()
}
popup.addButton(yesBtn)
popup.addButton(noBtn)
dialogAppearance.messageFont = UIFont(name: "Nunito-Black", size: 18)!
dialogAppearance.messageTextAlignment = .natural
dialogAppearance.titleFont = UIFont(name: "Nunito-Black", size: 22)!
buttonAppearance.titleFont = UIFont(name: "Nunito-Black", size: 22)!
let vc = popup.viewController as! PopupDialogDefaultViewController //!!!
vc.buttonAlignment = .horizontal /// Cannot infer contextual base in reference to member 'horizontal', Value of type 'PopupDialogDefaultViewController' has no member 'buttonAlignment'
self.present(popup, animated: true, completion: nil)
}
正如您在此处看到的,Creator 将按钮水平放置:
let vc = popup.viewController as! PopupDialogDefaultViewController
vc.buttonAlignment = .horizontal
但是当我这样做时,编译器会说“无法根据成员'horizontal'推断上下文基础”,“'PopupDialogDefaultViewController'类型的值没有成员'buttonAlignment' ”......正如我的代码中所标记的那样。
我应该怎么办?
解决方案
解决了:
直接写就行了
let popup = PopupDialog(title: title, message: message, buttonAlignment: .horizontal)
。
推荐阅读
- reactjs - React-Router-Dom不渲染页面
- caching - 为部分 graphQL 查询指定缓存策略
- c++ - 定义多维模板数组时递归如何工作?
- apache-spark - For Loop 在 EMR (pyspark) 中不断重启
- clips - 如何停止对已修改事实的规则重复激活?
- python - 在数据框中查找日期并将数据附加到不同的数据框 PYTHON
- html - 为什么不能在图像之后放置 '::after' 伪选择器?
- c# - 蜡烛数组从响应到历史对象列表的转换。正文中的其他细节
- alteryx - 如何控制不相关的 Alteryx IO 任务的执行顺序?
- css - 图像和文本换行之前的 Psuedo