Domanda

I am having a TTStyledSheet which works fine on load. But when i reload the view, the styling is lost.

  1. I have a UITableViewController
  2. Each cell in the tableview has a TTStyledTextLabel
  3. I have a reload mechanism for the tableview

When the view loads, the styling is all perfect and as i expect it to be. But, when i reload the table, the styling is totally lost

In my feedView.m file i have the stylesheet like this

@interface feedViewStyleSheet : TTDefaultStyleSheet
@end

@implementation feedViewStyleSheet

- (TTStyle*)smallGrayText {
    TTTextStyle *style=[[TTTextStyle alloc] init];
    [style setFont:[UIFont fontWithName:@"HelveticaNeue" size:9]];
    [style setColor:[[GlobalFunctions sharedGlobalFunctions] UIColorFromRGB:85 :85 :85]];
    [style setNext:nil];
    return [style autorelease];
}
- (TTStyle*)smallBlueText {
    TTTextStyle *style=[[TTTextStyle alloc] init];
    [style setFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:14]];
    [style setColor:[[GlobalFunctions sharedGlobalFunctions] UIColorFromRGB:144 :5 :5]];
    [style setNext:nil];
    return [style autorelease];
}


- (TTStyle*)smallText {
    return [TTTextStyle styleWithFont:[UIFont fontWithName:@"HelveticaNeue" size:12] next:nil];
}


@end
#pragma mark {End TTStyles}

In the view's init i have this

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        //  TTStyleSheet styles
        [TTStyleSheet setGlobalStyleSheet:[[feedViewStyleSheet alloc] init] ];          

    }
    return self;    
}

I tried to debug; for each cell when i printed [TTStyleSheet globalStyleSheet] for each cell. When the app launches, and when it is as i expect it to be. The debug output is as follows

2012-05-29 17:26:17:961 MFace[41092:12803] Cell 0 Style: <feedViewStyleSheet: 0x7f7d240>
2012-05-29 17:26:17:978 MFace[41092:12803] Cell 1 Style: <feedViewStyleSheet: 0x7f7d240>

But when i reload (that's when the style's are lost), the output is

2012-05-29 17:26:22:228 MFace[41092:12803] Cell 0 Style: <TTDefaultStyleSheet: 0x7f12030>
2012-05-29 17:26:22:228 MFace[41092:12803] Cell 1 Style: <TTDefaultStyleSheet: 0x7f12030>

And it looks' like the stylesheet is not available on reload. I even tried removing "autorelease' during init. But it's still the same.

I am not sure why this is happening. Any suggestions?

And yes, i don't have a TTNavigator in my app, am just trying to use only the TTStyleSheet and styledText and a few other components.

Thanks

È stato utile?

Soluzione

I am not sure how to solve this; but i believe TTStyles are getting released or non-existent on reload. So i re-declared them each time i am reloading the table. Not sure if this is a good approach. But that worked for me.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top