Reputation: 309
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";
}
Upvotes: 1
Views: 740
Reputation: 5280
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!
Upvotes: 0
Reputation: 1516
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.
Upvotes: 0