Swift 应用在 iOS 7 上 运行

Swift app does not run on iOS 7

我正在 swift 中为 iOS7 和 iOS8 兼容创建一个应用程序。对于模拟器和设备,我的应用程序可以轻松地在 iOS8(作为部署目标)中运行。但它不是 iOS7 中的 运行 作为 "Info" 选项卡下的部署目标。对于 iOS7,如果我选择 iPhone 5s(8.1) 模拟器那么它可以工作,但是如果选择 7.0/7.1 sdk/iPhone 设备的任何模拟器,那么我的应用程序会崩溃。我应该怎么办?我在 xcode 中 "build settings" 选项卡上的基本 SDK 是 iOS 8.1。下面是我的代码。我的应用程序在以下代码的 "UISearchController(searchResultsController: nil)" 处崩溃。任何建议都必须是可观的。

 override func viewDidLoad() {
        super.viewDidLoad()

        // Search Controller Setup
        searchController = UISearchController(searchResultsController: nil)
        searchController.searchBar.delegate = self
        searchController.searchResultsUpdater = self
        searchController.dimsBackgroundDuringPresentation = false
        searchController.searchBar.placeholder = "ব্র্যান্ড/সংস্থা/দোকান খুঁজুন"

        // Make sure the that the search bar is visible within the navigation bar.
        searchController.searchBar.sizeToFit()
        tableView.tableHeaderView = searchController.searchBar
        definesPresentationContext = true
    }

UISearchController 可从 IOS8 获得,如果您想在 IOS7 中使用类似的东西,您应该使用 UISearchDisplayController(在 IOS8 中已弃用)。