:Three20의 TTLauncherView 사용 : 필요 분할과 도움에있는 NSArray에있는 NSMutableArray에서 나머지 개체를 추가 오브젝티브 C
- (void)loadLauncher:(NSMutableArray *)categoriesArray {
_launcherView = [[TTLauncherView alloc] initWithFrame:self.view.bounds];
_launcherView.columnCount = 3;
// Number of pages in your launcherView.
NSMutableArray *pages = [[NSMutableArray alloc] initWithCapacity:2];
int numberOfObjects = [categoriesArray count];
// The launcherItems in each page, calculate automatically the number of objects available for the launcher.
NSMutableArray *launcherItems = [[NSMutableArray alloc] initWithCapacity:1];
// The counter to identify if the number of objects exceeds the,
// capacity of a launcher page of 9.
int j = 1;
for (int i = 0; i < numberOfObjects; i++){
if (j > 9){
// Add the current launcherItems array to the pages.
[pages addObject:launcherItems];
// Initialise new launcher items.
launcherItems = [[NSMutableArray alloc] initWithCapacity:1];
// Start the counter again.
j = 1;
} else {
int i = 0;
for (Category *c in categoriesArray) {
NSString *categoryImage = [[NSString stringWithFormat:@"bundle://category_%@_icon.png", [Utility removeSpecialCharacters:@"&'- " withString:c.categoryName]] lowercaseString];
NSLog(@" - %@", categoryImage);
TTLauncherItem *launcherItem = [[[TTLauncherItem alloc] initWithTitle:c.categoryName
image:categoryImage
URL:[NSString stringWithFormat:@"%d", i]
canDelete:NO] autorelease];
[launcherItems addObject:launcherItem];
i++;
}
}
j++;
}
// Add the current launcherItems to the pages.
[pages addObject:launcherItems];
[launcherItems release];
_launcherView.pages = pages;
[self.view addSubview:_launcherView];
}
오래된 방법
내가 사용하고 TTLauncherView
컨트롤러부터 http://three20.info.
Three20은 App Store에서 인기있는 응용 프로그램의 인기를 강화하는 Objective-C 클래스 모음입니다. 그것은 당신에게 개발 시간을 절약 할 수있는 매우 유용한 기능을 제공합니다.
라이브러리는 모듈 식으로 제작되므로 라이브러리의 요소를 선택적으로 프로젝트에 통합 할 수 있습니다. 또한 드롭 인 XML 및 JSON 구문 분석과 응용 프로그램 테마를위한 CSS 스타일 시트 지원을 비롯한 확장 기능 세트가 늘어나고 있습니다.
나는 다음을 수행하는 방법을 아주 확실하지 않다 : 내 arrayOfLauncherItems
이 16 개체가 있는지 여부를
- 확인; 및
- 개체가 16 개 이상이면 나머지 나머지 개체를
_launcherView.pages
에 추가하십시오. 그래서 총 32 개의 객체가 있다고 가정하면 나머지 16 개의 객체 중 다른 배열을 만들어_launcherView.pages
NSArray
에 추가 할 수 있기를 원합니다.
이는 TTLauncherView
컨트롤러의 작동 방법의 일 예이다 :
TTLauncherView *_launcherView = [[TTLauncherView alloc] initWithFrame:self.view.bounds];
NSMutableArray *arrayOfLauncherItems = [[NSMutableArray alloc] init];
//add TTLauncherItem objects to arrayOfLauncherItems.
_launcherView.pages = [NSArray arrayWithObjects:arrayOfLauncherItems, nil];
arrayOfLauncherItems
나머지 TTLauncherItem
개체 (두 번째, 세 번째 페이지에이어야하며 즉, 16 개 이상의 물체를 포함 할 수있다 얼마나 많은 총 물체가 있는지에 따라).
다음과 같이하면 arrayOfLauncherItems
에서 동일한 16 개의 개체가 추가됩니다. 즉, 두 번째 페이지가 있음을 의미합니다. 즉, arrayOfLauncherItems
에 32 개 이상의 개체가 있으면 기본적으로 달성하고 싶은 페이지입니다.
_launcherView.pages = [NSArray arrayWithObjects:arrayOfLauncherItems, arrayOfLauncherItems, nil];
원래 질문을 업데이트하고 코드를 사용했습니다. 하지만 두 페이지 모두에서 같은 항목을 가져 오지는 않습니다. 또한 페이지 수에 대해 initWithCapacity를 2로 설정하십시오. 총 항목 수에 2보다 많은 페이지가있는 경우 어떻게 제어 할 수 있습니까? – fuzz
이 버그로 저를 도울 수 있습니까? 그러나 지금 당신의 코드를 사용하고 있습니다. columnCount를 3으로 사용하고 있는데, 페이지 당 총 9 개의 카테고리를 제공합니다. 문제는 10 번째 항목이 표시되지 않는 것입니다. 단순히 10 번째 항목을 건너 뛰고 2 번째 페이지로 이동하지만 11 번째 항목 항목부터 시작합니다. 이걸 내게 주시겠습니까? – fuzz
안녕하세요 풀비오, 지연에 대해 유감스럽게 생각하며 귀하의 의견을 알지 못했습니다. 작동하는 경우 업데이트 된 코드를 확인하십시오. –