如何在 iphone/ipod 状态栏添加图标?
苹果不允许开发者在状态栏中添加图标吗?
我按照书上的代码进行操作。代码很简单:
@interface UIApplication (extended)
- (void) addStatusBarImageNamed:(NSString *)aName;
- (void) removeStatusBarImageNamed:(NSString *)aName;
@end
- (void)performAction{
if (xxx) {
[[UIApplication sharedApplication]addStatusBarImageNamed:@"Default_EN.png"];
}
else {
[[UIApplication sharedApplication]addStatusBarImageNamed:@"Default_EC.png"];
}
}
但它给出了以下反馈:
-addStatusBarImageNamed:已弃用。什么也不做。
我能做些什么?
Does Apple not allow developers to add an icon into a status bar?
I followed code from a book. The code is simple:
@interface UIApplication (extended)
- (void) addStatusBarImageNamed:(NSString *)aName;
- (void) removeStatusBarImageNamed:(NSString *)aName;
@end
- (void)performAction{
if (xxx) {
[[UIApplication sharedApplication]addStatusBarImageNamed:@"Default_EN.png"];
}
else {
[[UIApplication sharedApplication]addStatusBarImageNamed:@"Default_EC.png"];
}
}
But it gives the following feedback :
-addStatusBarImageNamed: is deprecated. Doing nothing.
What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,SDK 中不允许这样做,但他们可能有一些私有 API 来执行此操作,但到目前为止他们还没有公开这些,我认为你无法在状态栏中添加图标。 如果有人知道请纠正我。
To my best knowledge, this isn't permitted within the SDK, but there could be the possibilities that they could have some private API to do so but so far they haven't exposed those, I think you are'nt able to add icon in status bar. If someone know please correct me .
在 Classes/YourViewController.m 中,需要用此覆盖 addStatusBarImageNamed:removeOnExit: 方法。
看看它是否工作正常。
In Classes/YourViewController.m, the addStatusBarImageNamed:removeOnExit: method needs to be overwritten with this.
See if it works fine.