1

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];
}
}
Luis Andrés García
  • 5,852
  • 10
  • 43
  • 57

2 Answers2

3

After adding your icons juste call [launcherView scrollToItem:item1 animated:NO]

Mathieu Hausherr
  • 3,485
  • 23
  • 30
0

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.

tonklon
  • 6,777
  • 2
  • 30
  • 36
  • Changing the animated property to NO for every items, is still not working out. I add every item in this way to reuse it afterwards when I add or remove any item element by element. Nevertheless, what you suggets gives better performance. Now, I am trying to find out why setting animated to NO is not working. – Luis Andrés García Feb 26 '12 at 15:24
  • 1
    I have moved the scrollToItem method invocation to viewDidAppear, and the scrolling works, although the scrolling movement is shown. – Luis Andrés García Feb 26 '12 at 15:40