辞职急救员

时间:2016-03-13 19:39:12

标签: swift

我想知道每当我切换到我的detailView时如何摆脱我的搜索栏,所以每当我切换到detailView时,我都不必在搜索栏上按下取消。

这是我的detailView代码。

import UIKit

class DetailViewLemon: UIViewController {

var sentData1:String!


@IBOutlet weak var DetailCarMake: UILabel!
@IBOutlet weak var Zacks: UILabel!
@IBOutlet weak var TheStreet: UILabel!
@IBOutlet weak var MarketWatch: UILabel!
@IBOutlet weak var StockMaster: UILabel!
@IBOutlet weak var Nasdaq: UILabel!
@IBOutlet weak var InvestorPlace: UILabel!
@IBOutlet weak var Benzinga: UILabel!
@IBOutlet weak var Rating: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()


    DetailCarMake.text = sentData1


    self.title = sentData1


    if self.title == "Apple" {


        Zacks.text = "Zacks Rank: Buy"

        TheStreet.text = "The Street: Buy"

        MarketWatch.text = "MarketWatch: Buy"

        StockMaster.text = "StockMaster: Buy"

        Nasdaq.text = "Nasdaq Rating: Buy"

        InvestorPlace.text = "InvestorPlace Rating: Buy"

        Benzinga.text = "Benzinga Rating: Buy"

        Rating.text = "Buy"
    }

    if self.title == "Google" {


        Zacks.text = "Goog Zacks Rank: Buy"

        TheStreet.text = "Goog The Street: Buy"

        MarketWatch.text = "MarketWatch: Buy"

        StockMaster.text = "StockMaster: Hold"

        Nasdaq.text = "Nasdaq Rating: Buy"

        InvestorPlace.text = "InvestorPlace Rating: Hold"

        Benzinga.text = "Benzinga Rating: Buy"

        Rating.text = "Buy"
    }






}

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



}

2 个答案:

答案 0 :(得分:1)

在您prepareForSegue的{​​{1}}中,您应该调用TableViewController(用实际上的任何内容替换变量的名称,因为您没有显示该代码。

答案 1 :(得分:0)

你也可以在viewWillDisappear中使用“view.endEditing(true)”

func viewWillDisappear(animated: Bool) {
     super.viewWillDisappear(animated)
     view.endEditing(true)
}

无论哪个输入是FirstResponder

,它都会关闭键盘