Three20问题:如何刷新TTLauncherItem/更改图像
将 TTLauncherItem 添加到 TTLauncherView 后,我想更改添加的 TTLauncherItem 的图像。
但是当我更改图像的值时,它不起作用。视图上没有任何变化。
如何立即刷新 TTLauncherItem 的图像?
感谢先进~~~~
init 方法是,
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];
/////////以下几行更改。
TTLauncherItem *testItem = [[pagesArray objectAtIndex:0] objectAtIndex:0];
testItem.image = @"bundle://defaultMusic2.png";
/////////////
但如果我将其移动到另一个方法,例如我的 ImageDidLoad,然后获取 TTLauncherItem 对象,更改其图像,它根本不起作用...... 或者这个:
- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item {
TTLauncherItem *testItem = [[_launcherView.pages objectAtIndex:0] objectAtIndex:4];
testItem.image = @"bundle://defaultMusic2.png";
}
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";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定这是否符合您的需求(并且诚然不是最漂亮的解决方案),但您可以从超级视图中删除旧的 TTLauncherView 并使用新图像重新创建启动器视图。
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.
解决一下。
先保存页面,然后进行修改,然后恢复回来。
祝你好运!
just work it out.
save the pages firstly, and then make your amending, then restore back.
Good Luck!