Mike D
Mike D

Reputation: 4946

Setting tintColor on UITabBAr causes Application to Crash

I have the following code in my application:DidFinishLaunchingWithOptions: where I attempt to set tab bar tint colour:

UIColor *colour = [UAColors getSeasonalColour];

self.tabBarController.tabBar.tintColor = colour;    // SIGABORT here
[colour release];

getSeasonalColours is:

+(UIColor *)getSeasonalColour {
    UIColor *seasonalColour = 0;

    if ( [UADates isSpring:[NSDate date]] )
        seasonalColour = [UIColor greenColor];
    else if ( [UADates isSummer:[NSDate date]] )
        seasonalColour = [UIColor blueColor];
    else if ( [UADates isAutumn:[NSDate date]] )
        seasonalColour = [UIColor orangeColor];
    else if ( [UADates isWinter:[NSDate date]] )
        seasonalColour = [UIColor redColor];
    else
        seasonalColour = [UIColor blackColor];

    return seasonalColour;
}

Right now UADates is only a stub that returns true for isWinter.

Why would this cause a crash? Using the same getSeasonalColours works perfectly fine when I set the tintColor on a navigation bar.

Upvotes: 0

Views: 394

Answers (2)

jrturton
jrturton

Reputation: 119272

[colour release] should not be there, since your colours are all autoreleased. Are you sure that isn't the line that is crashing?

Upvotes: 2

MrMage
MrMage

Reputation: 7486

Setting a tab bar's tint color is only available starting with iOS 5 (and thus will crash on iOS 4 and earlier), while navigation bar tint colors have been around since iPhone OS 2.0.

Upvotes: 3

Related Questions