本文介绍了如何添加图标到iphone / ipod状态栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Apple不允许开发人员在状态栏中添加图标吗?
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"];
}
}
但它给出以下反馈:
我能做什么?
推荐答案
在类/ YourViewController.m 中, addStatusBarImageNamed:removeOnExit:方法需要被覆盖。
In Classes/YourViewController.m, the addStatusBarImageNamed:removeOnExit: method needs to be overwritten with this.
- (void) addStatusBarImageNamed:(NSString*)image removeOnExit: (BOOL) remove {
if(_statusbarimage!=nil && _responds) {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarEnabled"] integerValue] == 1)
[self removeStatusBarImageNamed:_statusbarimage];
statusbarimage=image;
}
if (_responds) {
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarEnabled"] integerValue] == 1)
[super addStatusBarImageNamed:image removeOnExit: remove];
}
}
看看是否正常。
这篇关于如何添加图标到iphone / ipod状态栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!