ios - 导航栏中心的事件指示器

标签 ios xcode uinavigationcontroller uinavigationbar

在我的应用程序中,我想在导航栏的中心(标题位置)添加事件指示器。当 Web 服务响应完成时,它应该替换为旧标题。我的应用程序中有 5 个导航栏。当我在谷歌中搜索时,我有几个代码,但他们只是在更改左栏或右栏按钮。有什么帮助吗?

最佳答案

您可以使用导航项的 titleView 属性来替换导航栏的标题。所以要添加一个事件指示器,只需这样做:

    UIActivityIndicatorView *aiView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    aiView.hidesWhenStopped = NO; //I added this just so I could see it
    self.navigationItem.titleView = aiView;

当你想删除它并再次显示标题时:

    self.navigationItem.titleView = nil;

关于ios - 导航栏中心的事件指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16057034/

相关文章:

cocoa - Xcode : cannot change main nib file

iphone - UINavigationController 泄漏/理解 popViewController

ios - UITableView 中的自动滚动更顺畅

iphone - UITableViewCell 内的 UITextField 在滚动时被删除

ios - NSKeyedArchiver 线程安全吗?

ios - 使用 afnetworking 3.0.4 时发生崩溃,[NSProgress setTotalUnitCount :], 谁能告诉我原因

ios - 选择不同的选项卡时更改导航栏标题

来自核心数据的值之间的 Objective-C 类型错误

ios - 一起使用 UITabBarController 和 UINavigationController

ios - 幸存的ios内存警告