Three20问题:如何刷新TTLauncherItem/更改图像

发布于 2024-10-04 09:07:13 字数 1454 浏览 0 评论 0原文

将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

辞旧 2024-10-11 09:07:13

不确定这是否符合您的需求(并且诚然不是最漂亮的解决方案),但您可以从超级视图中删除旧的 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.

想念有你 2024-10-11 09:07:13

解决一下。

先保存页面,然后进行修改,然后恢复回来。

    NSArray *pages = [_launcherView.pages copy];

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

祝你好运!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文