ios - UIViewController 上的多个 UILabel

标签 ios swift uiviewcontroller uilabel

我正在尝试控制将两个 UILabel 拖放到 UIViewController 上。我不断收到 Cannot override strong property with weak property 错误。

这是我的代码的一小段摘录。这是所有错误的屏幕截图https://gyazo.com/bd97fa42443d12a3aa17a2de55f78b60

import UIKit

class ViewController: UIViewController {


@IBOutlet private weak var display: UILabel!

@IBOutlet private weak var description: UILabel!

private var userIsInTheMiddleOfTyping = false

@IBAction private func touchDigit(_ sender: UIButton) {
    let digit = sender.currentTitle!
    if (digit == "c") {
        display.text = " "
    } else {
        print("touchDigit \(digit) digit")
        if userIsInTheMiddleOfTyping {
            let textCurrentlyInDisplay = display.text
            if (sender.currentTitle!) == "c" {
                print("it printed c")
                display.text = "sam"

最佳答案

您需要重命名您的 description 变量,因为 description 是从 NSObject 继承的方法的名称( 的基类UIViewController).

关于ios - UIViewController 上的多个 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40167929/

相关文章:

iphone - 杀死应用程序后显示本地通知弹出窗口

ios - 在选择 CollectionViewCell 时将信息发送到详细 View

swift - 单击标签时如何显示另一个 View Controller

swift - 收到消息时将徽章添加到聊天按钮

swift - 如果我总是在不同的类中初始化一种类型的类,这对性能来说是好是坏?

ios - 在 IOS 6 上运行的应用程序在 IOS 5 中崩溃

ios - UIRefreshControl 未按正确顺序加载

swift - Swift 中的 UIViewController 与 tableView 或 TableViewController

ios - 带有七个选项卡的选项卡栏 Controller ,五个选项卡导致 Split View Controller

ios - 在不同的选项卡中弹出 View Controller