小编Dev*_*Dev的帖子

UISearchController保留问题

我正在尝试使用UISearchController但是我面临保留我无法解决的问题.MainTableview有两个部分.

第1节

过滤数据基于一些正则表达式

第2节

所有数据

我将UISearchController添加到我的tableview中,并将ResultsTableController作为resultsTableController附加.当用户搜索某些东西时,它工作,ResultsTableController出现,因为我将tableview委托设置为self,从我的MainTableViewController中的ResultsTableController调用didSelectRowAtIndexPath中选择项目.但是,如果用户从resultsTableController中选择了某些内容,则会出现分配问题.

以下是针对不同场景的

  • 用户不搜索任何内容,只需从MainTableview中选择一个项目,我就会看到deinit消息
  • 用户搜索内容,取消搜索,从MainTableview中选择项目,我看到deinit消息
  • 用户搜索某些东西,并从ResultsTableController中选择一个项目,我的视图控制器中没有得到deinit

MainTableViewController.swift

var searchController: UISearchController!

// Secondary search results table view.
var resultsTableController: ResultsTableController!
var allCompanies = ["Data1","Data2","Data3"]

override func viewDidLoad() {
    super.viewDidLoad()
     resultsTableController = ResultsTableController()
    // We want to be the delegate for our filtered table so didSelectRowAtIndexPath(_:) is called for both tables.
    resultsTableController.tableView.delegate = self
    searchController = UISearchController(searchResultsController: resultsTableController)
    searchController.searchResultsUpdater = self
    searchController.searchBar.sizeToFit()
    tableView.tableHeaderView = searchController.searchBar

    searchController.delegate = self
    searchController.dimsBackgroundDuringPresentation = false 
    searchController.searchBar.delegate = self   
    definesPresentationContext = true
    } …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift uisearchcontroller

4
推荐指数
2
解决办法
1049
查看次数

CoreData Swift 3 - 如何加入两个实体?

我有两个实体"CAR"和"COLOR".

在"COLOR"中,我有两个属性.

  1. ID
  2. 名称

在"CAR"中,我有三个属性.

  1. ID
  2. colourId
  3. carName

"COLOR"的id与"CAR"中的colourId相关.

请有人帮我写一个谓词,用于生成一种颜色的汽车阵列吗?

core-data nspredicate ios swift3

1
推荐指数
1
解决办法
1345
查看次数