NavigationBar 和 UIImagePickerController 的问题
在我的应用程序委托中,我有这个:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect
{
UIImage *image = [UIImage imageNamed: @"HeaderViewBG.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
用于设置导航栏的背景图像。但我需要使用 UIImagePickerController,所以我有以下代码:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.navigationBar.barStyle = UIBarStyleDefault;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
结果是:
我想要默认的 UIImagePickerController导航栏样式。我不想在应用程序中使用图像背景,我想要默认的导航栏。
我该如何修复它?
非常感谢。
in my app delegate I've this:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect
{
UIImage *image = [UIImage imageNamed: @"HeaderViewBG.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
for set a background image for navigationbar. But I need to use a UIImagePickerController, so I've this code:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.navigationBar.barStyle = UIBarStyleDefault;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
The result is:
I want the default UIImagePickerController navigationbar style. I don't want the image background used in application, I want the default navigationbar.
How can I fix it?
Very thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除导航栏的代码并删除调用drawRect此函数的语句。
它删除自定义导航栏,然后您将获得默认导航栏。
remove code for navigation bar and remove the statement where you call drawRect this function.
it remove the custom navigation bar and then you get default navigation bar.