当我向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];
}
}
答案 0 :(得分:3)
添加图标后,请致电[launcherView scrollToItem:item1 animated:NO]
答案 1 :(得分:0)
您正在添加动画的所有项目。我不认为这是你想要的viewDidLoad,另一方面,这是让你的代码不能按预期工作的原因。您正在添加动画项目,然后请求立即(非动画)移动到第一项。那次冲突。最简单的方法是添加没有动画[launcherView addItem:icono animated:NO];
但这不是你通常会向启动器添加很多项目的方式。它会产生很多开销。有一个pages
属性,更适合您的需求。查看TTCatalog示例应用程序以获取代码。