【问题标题】:Unable to stop animation and hide cancel button on searchBar of searchController无法在 searchController 的 searchBar 上停止动画并隐藏取消按钮
【发布时间】:2014-12-11 17:52:20
【问题描述】:

我在导航栏中设置了我的搜索栏。激活后,它会动画并出现取消按钮。我正在尝试停止动画并防止出现取消按钮。我的故事板是在 navigationController 中设置的 tableviewController。

self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;

self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0);

self.navigationItem.titleView = self.searchController.searchBar;
[self.searchController.searchBar setShowsCancelButton:NO animated:NO];

【问题讨论】:

    标签: ios navigationbar navigationcontroller searchbar


    【解决方案1】:

    试试[self.searchController.searchBar showsCancelButton:NO]

    【讨论】:

    • 不走运,我得到“'UISearchBar' 没有可见的@interface 声明选择器'showCancelButton'。
    • 我的错误。它是一个属性,所以它应该是[self.searchController.searchBar setShowsCancelButton:NO]self.searchController.searchBar.showsCancelButton = NO;
    猜你喜欢
    • 2017-12-14
    • 2020-11-11
    • 2021-02-10
    • 2016-09-20
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    相关资源
    最近更新 更多