- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 FirstViewController
中有 Collection View ,我想将数据从 Collection View 单元格传递到下一个 secondViewController
textField
。有四个文本字段,我在 XIB 中设计了这个文本字段并加载到 secondViewController
。基本上我必须将 textField 数据检查到数组中的 Collection View 单元格标签。
这是我的代码
import UIKit
class BackUpWord{
var label: String
var index: String
init(label:String, index:String) {
self.label = label
self.index = index
}
}
class FirstViewController: UIViewController {
@IBOutlet weak var collectionView: UICollectionView!
private var seed : Seed!
private var words : [String]!
var backupWords:[BackUpWord] = []
override func viewDidLoad() {
super.viewDidLoad()
cellIndex = 1
self.collectionView.isPagingEnabled = true
let entropy = Data.randomBytes(length: 32)
self.seed = Seed.init(entropy: entropy)!
words = self.seed.toBIP39Words()
var index = 1
for item in words! {
backupWords.append(BackUpWord.init(label: item, index: index.description))
index = index + 1
}
}
extension FirstViewController: UICollectionViewDelegate, UICollectionViewDataSource{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// return backupWords.count/2
return words.count/2
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! LabelCollectionViewCell
let even = backupWords[indexPath.row*2]
let odd = backupWords[indexPath.row*2+1]
cell.backUpWordFirst.text = even.label
cell.backUPWordSecond.text = odd.label
cell.index.text = even.index
cell.index2.text = odd.index
return cell
}
}
最佳答案
使用 collectionView 的 didSelect 委托(delegate):
func collectionView(UICollectionView, didSelectItemAt: IndexPath) {
var backupWord: BackUpWord = backupWords[indexPath.row]
let nextViewController = NextViewController = // Get next controller
// Assign values to nextViewController
// Push to next controller and assign values to textfields.
}
关于ios - 在 secondViewController 中有 4 个 textField 。我想用 firstviewController Collection View 单元检查这个 textField 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55327899/
我想在我的应用中包含 GameCenter 排行榜,但我有一个问题。 当我想显示 LeaderBoard 时,我使用以下代码: //shows leaderboard screen func show
当我运行我的应用程序时,我得到了这个我在控制台中看到此消息“Interface Builder 文件中的未知类 FirstViewController。” 我正在运行 TabBar 应用程序。 我该如
我目前的设计中有四个 View Controller ,我正在设计一个应用程序来销售产品。 FirstViewController获取产品图片,当用户点击下一个按钮时,它会将用户带到 secondvi
我在我的应用程序中使用了两个 View Controller 。我的 FirstViewController 中有一个按钮。当我选择按钮时,它会插入 SecondViewController。我在 S
我有三个 View Controller :FirstViewController 有两个标签,SecondViewController 只有一个文本字段,ThirdViewController 也有
首先我想说我已经搜索了这个错误的答案,但似乎没有一个答案适合我。 我想做的是将uiimage从一个vc传递到另一个,这是“应该”做的代码。但我收到错误“'FirstViewController' 没有
经过多次尝试,我没有成功理解错误以及为什么图像没有出现...这是我的代码。 我的协议(protocol).h #import @protocol myProtocol -(UIImage *)tr
我使用 Swift 3我的第一个 ViewController 中有一个 textfield,当我输入城市名称时,我希望它在 tableView 中打开该城市的药店 示例:当我在 textField
我在模拟我的应用程序时遇到了这个问题,它不是错误或警告,而是出现在我的控制台中,有没有人以前遇到过这个问题? 最佳答案 在我的例子中,当您快速单击 TableView 中的两个选项卡时会发生此错误。
抱歉我的英语不好 我需要将数据从我的第一个 View Controller 传递到 SWRevealViewController 的前 View Controller 在我的第一个 View Cont
在我的 app 中,我有三个 uiviewcontroller:firstviewcontroller、secondviewcontroller 和 thirdviewcontroller。 我使用导
FirstViewController 中的函数调用是 - @IBAction func redViewAct(sender :UIButton) { let nextview = s
我正在尝试使用 panGesture 将 secondViewController 从 firstViewController 的顶部移开,但我遇到了问题... 当我开始移动 secondViewCo
第一个 View Controller 。这就是问题所在。在我的“for 循环”中,它给了我一个错误。我尝试使用 Xcode 建议的方法,但它不起作用。我仍然认为自己是 Swift 的初学者。当人们发
我要推ViewController调用FirstViewController从其他观点来看,我做了: #import "FirstViewController.h" FirstViewControll
您好,我可以在 fourthviewcontroller 中访问来自 firstviewcontroller 的字符串吗?我使用了以下代码。但是当我转到 fourthviewcontroller 时,
今天我拆分了我的 Storyboard,现在我遇到了一个错误,我不知道如何修复它。 我有一个 Storyboard(产品),其中包含第一个选项卡中的所有 UIViewController,还有另一个
我正在尝试创建出现在最顶部 View Controller 上的通用警报,而底部 View Controller 仍然可以点击。此警报只是一个 20 点高的状态行,用于通知用户网络可达性。如何使 UI
我试图弄清楚如何在 Swift 中解决这个问题,但我也遇到了这个错误:“ fatal error :在展开可选值时意外发现 nil”。任何建议表示赞赏。谢谢。 来自 FirstViewControll
我收到错误提示,“类型‘FirstViewController’没有成员‘keepTimer’”和“使用未解析的标识符‘keepTimer’”。 我做错了什么?我应该如何改变这个?我的主要目标是让秒表
我是一名优秀的程序员,十分优秀!