Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在TTLauncher视图中加载更多页面_Iphone_Objective C_Ios_Xcode_Three20 - Fatal编程技术网

Iphone 在TTLauncher视图中加载更多页面

Iphone 在TTLauncher视图中加载更多页面,iphone,objective-c,ios,xcode,three20,Iphone,Objective C,Ios,Xcode,Three20,在我的TTLauncherView实现中,只加载第一页。为什么? 我在数组中有47个项目,47个项目按页面划分为9个项目,我应该有6个页面 谢谢你的帮助 - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSMutableString *jsonString = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8St

在我的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];  

}

我记得,TTLauncherView不会自动将TTLauncherItem拆分为页面。您需要一个数组。第一个数组中的所有启动器项目都将显示在第一页上,第二个数组中的所有启动器项目都将显示在第二页上,等等。我已经很久没有使用它了,但我想这就是它的工作原理。

我修改的代码中有@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];      

}