Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-26-2011, 05:16 PM   #1 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default UIImagePicker's UINavigationBar is abiding to drawRect. How can I stop this?

Hi,

I am using the following code to set the backgrounds of all UINavigationBars in my application. However, when I load the UIImagePicker, its' UINavigationBar will have the same backgroundView as all of the other UINavigationBars in my application.

How could I prevent this from happening?

Max

Code:
@implementation UINavigationBar (UINavigationBarCategory)

- (void) drawRect:(CGRect)rect {
    [[UIImage imageNamed:@"NavBarSocial.png"] drawInRect:rect];
}
@end
iSDK is offline   Reply With Quote
Old 05-27-2011, 11:45 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

If I understand correctly, you want all UINav controllers except the imagepicker's to have you custom nav bar?

Code:
- (void) drawRect:(CGRect)rect {
  if( [self isKindOfClass: [UIImagePickerController class]])
  {
     [super drawRect: rect];
   }
   else [[UIImage imageNamed:@"NavBarSocial.png"] drawInRect:rect];
}
smithdale87 is offline   Reply With Quote
Old 05-27-2011, 11:51 AM   #3 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

The category is just implemented in one of my .m files it is not part of a custom UINavigationBar. Therefore the code wouldn't work as a 'self''s class is of UINavigationBar class rather than UIImagePickerClass. But yes, that is what I would like.

Quote:
Originally Posted by smithdale87 View Post
If I understand correctly, you want all UINav controllers except the imagepicker's to have you custom nav bar?

Code:
- (void) drawRect:(CGRect)rect {
  if( [self isKindOfClass: [UIImagePickerController class]])
  {
     [super drawRect: rect];
   }
   else [[UIImage imageNamed:@"NavBarSocial.png"] drawInRect:rect];
}

Last edited by iSDK; 05-27-2011 at 12:45 PM.
iSDK is offline   Reply With Quote
Old 05-27-2011, 04:07 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

what about this:
Code:
-(void)drawRect:(CGRect)rect
{
    UIView* _super = [self superview];
    while(_super !=nil )
    {
        UIResponder* next = [_super nextResponder];
        if( [next isKindOfClass:[UIImagePickerController class]])
        {
              //if this UINavigationBar lives inside of a UIImagePickerController, 
             //then we'll use the default drawRect instead of our own
            [super drawRect:rect];   
             return;
        }
        _super = [_super superview];
    }
   
    [[UIImage imageNamed:@"NavBarSocial.png"] drawInRect:rect];
}

Last edited by smithdale87; 05-27-2011 at 04:16 PM. Reason: slight change
smithdale87 is offline   Reply With Quote
Old 05-27-2011, 04:19 PM   #5 (permalink)
Indie Developer
 
iSDK's Avatar
 
Join Date: Jul 2010
Posts: 1,346
iSDK is on a distinguished road
Send a message via AIM to iSDK
Default

Works perfectly, thanks a lot!

Quote:
Originally Posted by smithdale87 View Post
what about this:
Code:
-(void)drawRect:(CGRect)rect
{
    UIView* _super = [self superview];
    while(_super !=nil )
    {
        UIResponder* next = [_super nextResponder];
        if( [next isKindOfClass:[UIImagePickerController class]])
        {
              //if this UINavigationBar lives inside of a UIImagePickerController, 
             //then we'll use the default drawRect instead of our own
            [super drawRect:rect];   
             return;
        }
        _super = [_super superview];
    }
   
    [[UIImage imageNamed:@"NavBarSocial.png"] drawInRect:rect];
}
iSDK is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 345
6 members and 339 guests
doffing81, dre, iOS.Lover, jenniead38, Kirkout, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:11 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0