0

私の TTLauncherView の実装では、最初のページのみをロードします。なんで?

配列に 47 個のアイテムがあり、47 個のアイテムがページごとに 9 個のアイテムを分割しているため、6 ページが必要です。

助けてくれてありがとう。

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {      


NSMutableString *jsonString = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSDictionary *results = [jsonString JSONValue];

NSArray *photos = [[results objectForKey:@"photosets"] objectForKey:@"photoset"];

launcherView = [[TTLauncherView alloc] initWithFrame:self.view.bounds];
launcherView.backgroundColor = [UIColor whiteColor];
launcherView.delegate = self;
launcherView.columnCount = 3;

launcherView.persistenceMode = TTLauncherPersistenceModeNone;
NSMutableArray *itemArray = [[NSMutableArray alloc] init];
for (NSDictionary *photo in photos)   
{

     NSString *iconURLString = [NSString stringWithFormat:@"http://farm%@.static.flickr.com/%@/%@_%@_s.jpg", 
     [photo objectForKey:@"farm"], [photo objectForKey:@"server"], [photo objectForKey:@"primary"], [photo objectForKey:@"secret"]];


     NSDictionary *title = [photo objectForKey:@"title"];
     NSString *itemTitle = [title objectForKey:@"_content"];
     TTLauncherItem *itemMenu = [[[TTLauncherItem alloc] initWithTitle:itemTitle
                                                                 image:iconURLString
                                                                   URL:nil 
                                                             canDelete:NO] autorelease];

     [itemArray addObject:itemMenu];     

}

launcherView.pages = [NSArray arrayWithObject: itemArray];
[self.view addSubview:launcherView];  

}
4

2 に答える 2

0

@Darrenのヒントを使用して変更したコード

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {      

NSMutableString *jsonString = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];    
NSDictionary *results = [jsonString JSONValue];    
NSArray *photos = [[results objectForKey:@"photosets"] objectForKey:@"photoset"];
NSMutableArray *itemArray = [[NSMutableArray alloc] init];
NSMutableArray *pageArray = [[NSMutableArray alloc] init];
NSNumber *countPage = [[NSNumber alloc] initWithInt:0];

for (NSDictionary *photo in photos)   
{

    NSString *iconURLString = [NSString stringWithFormat:@"http://farm%@.static.flickr.com/%@/%@_%@_s.jpg", 
                               [photo objectForKey:@"farm"], [photo objectForKey:@"server"], [photo objectForKey:@"primary"], [photo objectForKey:@"secret"]];

    NSString *photoCount = [photo objectForKey:@"photos"];
    NSDictionary *title = [photo objectForKey:@"title"];
    NSString *itemTitle = [title objectForKey:@"_content"];
    TTLauncherItem *itemMenu = [[[TTLauncherItem alloc] initWithTitle:itemTitle
                                                                image:iconURLString
                                                                  URL:nil 
                                                            canDelete:NO] autorelease];
    itemMenu.badgeValue = photoCount; 

    [itemArray addObject:itemMenu];
    int value = [countPage intValue];
    countPage = [NSNumber numberWithInt:value + 1];
    if (countPage == [NSNumber numberWithInt:9]){
       countPage = [NSNumber numberWithInt:0]; 
       [pageArray addObject:itemArray];
        itemArray = [[NSMutableArray alloc] init];


    }

}
[pageArray addObject:itemArray];

launcherView = [[TTLauncherView alloc] initWithFrame:self.view.bounds];
launcherView.backgroundColor = [UIColor blackColor];
launcherView.delegate = self;
launcherView.columnCount = 3;    
launcherView.persistenceMode = TTLauncherPersistenceModeNone;    
launcherView.pages = pageArray;    
[self.view addSubview:launcherView];      

}
于 2012-08-06T13:57:22.933 に答える