【问题标题】:Xcode 10 button to create mad lips story will not run, I'm new to XcodeXcode 10 按钮创建疯狂的嘴唇故事不会运行,我是 Xcode 的新手
【发布时间】:2016-08-06 07:14:57
【问题描述】:

我刚开始使用 Xcode 10,无法让这个按钮为我疯狂的库创建工作。这只是为了好玩,但我很想知道如何解决它。请查看我的代码以了解为什么“创建故事”按钮未激活。

//  ViewController.swift
//  Field Button Fun
//
//  Created by Audrey Chao on 8/3/16.
//  Copyright © 2016 Maddie Chao. All rights reserved.

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var thePlace: UITextField!
    @IBOutlet weak var theVerb: UITextField!
    @IBOutlet weak var theNumber: UITextField!
    @IBOutlet weak var theTemplate: UITextView!
    @IBOutlet weak var theStory: UITextView!

    @IBAction func createStory(sender: AnyObject) {
        theStory.text = theTemplate.text
        theStory.text = theStory.text.stringByReplacingOccurrencesOfString("<place>", withString: thePlace.text!)
        theStory.text =   theStory.text.stringByReplacingOccurrencesOfString("<verb>", withString:   theVerb.text!)
 theStory.text =         theStory.text.stringByReplacingOccurrencesOfString("<number>", withString:         theNumber.text!)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        //thePlace.resignFirstResponder()
        // Do any additional setup after loading the view, typically from a       nib.
    }

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

【问题讨论】:

  • 你把动作连线了吗?换句话说,你需要告诉 Interface Builder createStory 是这个按钮的动作。
  • “不活跃”是什么意思?
  • @Sweeper 我想她的意思是当你点击它时,什么都没有发生。
  • 目前还没有 Xcode 10

标签: swift button


【解决方案1】:

您是否已将按钮连接到 IBAction?如果它们没有连接,Xcode 将无法判断您的按钮应该做什么。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-06
    • 2017-06-02
    • 2016-04-04
    • 2013-05-30
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    • 2015-11-27
    相关资源
    最近更新 更多