小编Apo*_*ote的帖子

如何在UISearchController中使用范围栏

我能够为UISearchController创建范围栏并设置它们的标题

    resultSearchController = ({

        let controller = UISearchController(searchResultsController: nil)

        controller.searchResultsUpdater = self

        controller.dimsBackgroundDuringPresentation = false

        controller.searchBar.showsScopeBar = true

        controller.searchBar.scopeButtonTitles = ["One", "two", "three"]

        controller.searchBar.sizeToFit()

        self.tableView.tableHeaderView = controller.searchBar


        return controller

    })()
Run Code Online (Sandbox Code Playgroud)

但是我如何使用范围栏进行实际排序.我目前的排序方法如下

func updateSearchResultsForSearchController(searchController: UISearchController) {

    filteredTableData.removeAll(keepCapacity: false)

    let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text)

    let array = (tableData as NSArray).filteredArrayUsingPredicate(searchPredicate)

    filteredTableData = array as! [String]

    tableView.reloadData()

}
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift uisearchcontroller

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

如何在react JS或React-Redux JS中验证CloudKit JS

我对网络开发非常陌生。我已经下载了 CloudKit JS 并在 script 标签中添加了 index.html 。我确保它在我的 React-Redux 包 JS 之前加载。

  <script src="/cloudkit.js"></script>
  <script src="/bundle.js"></script>
Run Code Online (Sandbox Code Playgroud)

我已经制作了单类组件,并且正在组件上运行身份验证,安装如下。

componentWillMount() {
CloudKit.configure({
  containers: [{
    containerIdentifier: '<container ID>',
    apiToken: '<secret api token>',
    environment: 'development'
  }]
});
var container = CloudKit.getDefaultContainer();
container.setUpAuth().then(function(userInfo) {
  if(userInfo) {
            console.log(userInfo);
        } else {
            console.log('need to login');
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

然后我得到以下错误在此输入图像描述 如何使用 CloudKit JS 在 React 中进行身份验证?

node.js reactjs cloudkit-web-services redux react-redux

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