首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在TTLauncherView中加载更多页面

在TTLauncherView中加载更多页面
EN

Stack Overflow用户
提问于 2012-08-05 21:54:46
回答 2查看 110关注 0票数 0

在我的TTLauncherView实现中,只加载第一个页面。为什么?

我在数组中有47个项目,47个项目按页划分9个项目,我应该有6个页面。

谢谢你的帮助。

代码语言:javascript
复制
- (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];  

}
EN

回答 2

Stack Overflow用户

发布于 2012-08-05 22:27:47

在我的记忆中,TTLauncherView不会自动将TTLauncherItem拆分成页面。你需要一个数组的数组。第一个数组中的所有启动器项都将在第一页上,第二个数组中的所有启动器项都将在第二页上,依此类推。我已经很长时间没有使用它了,但我想这就是它的工作方式。

票数 0
EN

Stack Overflow用户

发布于 2012-08-06 21:57:23

我修改后的代码带有@Darren提示

代码语言:javascript
复制
- (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];      

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11816997

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档