David
David

Reputation: 4895

I can't use method declared in subclass

I'm trying to use this project but I end up with a problem. The main goal is to set some gradient color to UiNavigationBar using StoryBoard.

1 -

#import "CRGradientNavigationBar.h"

2 -

enter image description here BECOMES enter image description here

3 -

    // array of colors
UIColor *firstColor  = [UIColor colorWithRed:255.0f/255.0f green:42.0f/255.0f blue:104.0f/255.0f alpha:1.0f];
UIColor *secondColor = [UIColor colorWithRed:255.0f/255.0f green:90.0f/255.0f blue:58.0f/255.0f alpha:1.0f];
NSArray *colorsArray = [NSArray arrayWithObjects:firstColor, secondColor, nil];

    // setting the navigation bar color
[self.navigationController.navigationBar setBarTintGradientColors:colorsArray];

    // 
NSLog(@"%@", self.navigationController.navigationBar);

The error is

No visible @interface for 'UINavigationBar' declares the selector 'setBarTintGradientColors:'

knowing that setBarTintGradientColors is declared in CRGradientNavigationBar.h

And the NSLog output is

2014-06-23 21:07:04.388 Project[1794:60b] <CRGradientNavigationBar: 0xa5324d0; baseClass = UINavigationBar; frame = (0 20; 320 44); opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0xa536060>; layer = <CALayer: 0xa5327e0>>

How can I solve it ?

Upvotes: 0

Views: 67

Answers (1)

Colin
Colin

Reputation: 3752

self.navigationController.navigationBar returns a UINavigationBar, not a CRGradientNavigationBar. You could cast it:

[(CRGradientNavigationBar *)(self.navigationController.navigationBar) setBarTintGradientColors:colorsArray];

Upvotes: 2

Related Questions