Three20 TTLauncherView 默认显示菜单的第一页
当我向 TTLauncherView Three20 视图添加一些图标 (50) 时,TTLauncherView 始终位于图标页面的最后一页。如何更改它以始终显示图标的第一页而不是最后一页? 谢谢。
在 viewDidLoad 方法中更新
,我称之为:
- (void)loadIcons
{
int first=0;
TTLauncherItem *firstIcon;
for (NSString *nombre in nombres) {
TTLauncherItem *icono=[self generarIcono:nombre];
[launcherView addItem:icono animated:YES];
if(first==0)
firstIcon=icono;
first=1;
}
[self.view addSubview:launcherView];
if (firstIcon!=nil) {
[launcherView scrollToItem:firstIcon animated:NO];
}
}
When I add some icons (50) to the TTLauncherView Three20 view, TTLauncherView is always in the last page of the pages of icons. How can I change it to always show the first page of icons instead of the last one?
Thanks.
Update
in the viewDidLoad method, I call this one:
- (void)loadIcons
{
int first=0;
TTLauncherItem *firstIcon;
for (NSString *nombre in nombres) {
TTLauncherItem *icono=[self generarIcono:nombre];
[launcherView addItem:icono animated:YES];
if(first==0)
firstIcon=icono;
first=1;
}
[self.view addSubview:launcherView];
if (firstIcon!=nil) {
[launcherView scrollToItem:firstIcon animated:NO];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加图标后,只需调用
[launcherView rollToItem:item1animated:NO]
After adding your icons juste call
[launcherView scrollToItem:item1 animated:NO]
您正在添加所有动画项目。我认为这不是您在 viewDidLoad 期间想要的,另一方面,这也是您的代码无法按预期工作的原因。您正在添加动画项目,然后请求立即(非动画)移动到第一个项目。这会发生冲突。最简单的方法是添加不带动画的项目
[launcherView addItem:iconanimated:NO];
但这通常不是向启动器添加大量项目的方式。它会产生大量开销。有一个
pages
属性更适合您的需求。查看 TTCatalog 示例应用程序的代码。You are adding all the items animated. I don't think that is what you want during viewDidLoad and on the other hand, this is what keeps your code from working like you expected. You are adding items animated and then request an immediate (not animated) move to the fist items. That clashes. The simplest thing to do is to add the items without animation
[launcherView addItem:icono animated:NO];
But that is not the way you would normally add a lot of items to the launcher. It creates a lot of overhead. There's a
pages
property, that is better suited for your needs. Look a the TTCatalog example app for code.