Problem of Three20: How to refresh TTLauncherItem /change the image

741 views Asked by At

After adding TTLauncherItem into TTLauncherView, I want to change the image for the added TTLauncherItem。

But when I changed the value of image, it was not working. There is no change on the view.

How can I refresh image of TTLauncherItem immediately?

Thanks advanced~~~~

the init method is,

 for (int i = 0; i < pages; i++) {

    NSMutableArray*    pageArray = [NSMutableArray array];
    for (int j = 0; j<pageCount && (j+i*pageCount)<[titleArray count]; j++) {

        [pageArray addObject:[[[TTLauncherItem alloc] initWithTitle:[titleArray objectAtIndex:(j+i*pageCount)]
                                                              image:@"bundle://Icon.png"
                                                                URL:@"tt://setUp" 
                                                          canDelete:NO] autorelease]];
    }
    [pagesArray addObject:pageArray];
}

_launcherView.pages = [NSArray arrayWithArray:pagesArray];

[self.view addSubview:_launcherView];

/////////The following lines change.

TTLauncherItem *testItem = [[pagesArray objectAtIndex:0] objectAtIndex:0];
testItem.image = @"bundle://defaultMusic2.png";

/////////////

but if I move that to another methods such as my ImageDidLoad, then get the TTLauncherItem object, change the image of this, it does not work at all... or this:

- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item {
TTLauncherItem *testItem = [[_launcherView.pages objectAtIndex:0] objectAtIndex:4];
testItem.image = @"bundle://defaultMusic2.png";

}

2

There are 2 answers

0
ZYiOS On

just work it out.

save the pages firstly, and then make your amending, then restore back.

    NSArray *pages = [_launcherView.pages copy];

    // here to amend the items
    // something like item.xxx=xxx;
    [_launcherView setPages:pages];
    [pages release];

Good Luck!

0
Andrew Flynn On

Not sure if this fits your needs (and admittedly is not the prettiest solution), but you could remove the old TTLauncherView from the superview and re-create the launcher view with the new image.