iphone - 如何通过 UIButton 将 UITextfield 发送到变量?

标签 iphone swift uibutton uitextfield uilabel

我想知道如何在 UITextfield 中输入内容,然后通过 UIButton 将其发送到变量?

当我使用此代码尝试时,应用程序会自动崩溃并显示此错误:

Thread:1 signal SIGABRT

代码如下:

  import UIKit
  import Foundation

  class ViewController: UIViewController {

@IBOutlet weak var LabelHeure: UILabel!

@IBOutlet weak var Heure: UITextField!

@IBAction func Send(sender: AnyObject) {
     var one = String(Heure.text)
}
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.


    LabelHeure.text = NSDateFormatter.localizedStringFromDate(NSDate(),dateStyle:NSDateFormatterStyle.MediumStyle,timeStyle: NSDateFormatterStyle.NoStyle)

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.

}

}

最佳答案

您不需要将 Heure.text 转换为字符串,因为它已经是一个字符串。

关于iphone - 如何通过 UIButton 将 UITextfield 发送到变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31976270/

相关文章:

iphone - 如何在 UITabBarController 中获得完全透明的 TabBar

ios - 将共享文档文件夹中的文档加载到WKWebView中

ios - UITableViewCell 中的 UIButton 是可点击的(获取正确的事件)但问题是点击效果不可见

objective-c - UIButton 中的图像比原始图像更暗

ios - StartUpdatingLocation 进行错误处理

ios - 有没有什么东西会重复touchesBegan?

iphone - 如何检测何时在 uikeyboard 类型 "ABC"上点击 "UIKeyboardTypeNumbersAndPunctuation"按钮

iphone - 如何在 iphone 应用程序启动时打开不同的 View Controller ?

iPhone 在视频上进行图像叠加时出现 AVErrorInvalidVideoComposition 错误?

swift - UISearchbar TextField 的高度可以修改吗?