【发布时间】:2011-01-24 17:33:02
【问题描述】:
我有一个通用应用程序,我可以在其中自定义 UINavigationBar。 在我的 iPhone AppDelegate 中,我使用它来实现它:
@implementation UINavigationBar (CustomImage)
static NSMutableDictionary *navigationBarImages = NULL;
- (void)initImageDictionary
{
if(navigationBarImages==NULL){
navigationBarImages=[[NSMutableDictionary alloc] init];
}
}
- (void)drawRect:(CGRect)rect
{
NSLog(@"drawing navbar2");
UIImage *imageName=[navigationBarImages objectForKey:[NSValue valueWithNonretainedObject: self]];
if (imageName==nil) {
imageName=[UIImage imageNamed:@"bg_titleBar.png"];
UIImage *image = imageName;
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
}
- (void)setMyImage:(UIImage*)image
{
[navigationBarImages setObject:image forKey:[NSValue valueWithNonretainedObject: self]];
[self setNeedsDisplay];
}
@end
现在我的问题是:为什么会调用这段代码,尽管我启动了 iPad 模拟器?
更重要的是,它似乎破坏了 UIPopoverController,因为它看起来像这样:
http://awesome-apps.com/pic/ok.png
虽然它应该看起来像这样:
http://awesome-apps.com/pic/nok.png
除了它在我的应用程序中损坏更多,但对于初学者来说应该是这样 :)
谁能帮我解决这个问题?你有过类似的经历吗?
【问题讨论】:
-
添加:我刚刚意识到,实际上一切都很好,但是 Popover 的框架让它看起来有点奇怪。有没有办法自定义弹出框或删除它?
标签: iphone uinavigationcontroller customization uipopovercontroller