【发布时间】: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