Temat: UIScrollView i interakcja elementow
Inicjalizacja scrollView:
scroll = [[CustomScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[scroll setDelegate:self];
scroll.backgroundColor = [UIColor whiteColor];
scroll.pagingEnabled = YES;
scroll.showsHorizontalScrollIndicator = NO;
Metoda budujaca widok:
-(UIView*)buildView:(int)currentPageNUM {
UIView *ret = [[[UIView alloc]init] autorelease];
int yCounter = 0;
int xCounter = 0;
NSMutableArray *arr = [[NSMutableArray alloc] init];
SearchResultItem *item;
for (int i = currentPageNUM * 6; i < MIN((currentPageNUM + 1) * 6, [data count]); i++) {
int j = i - (currentPageNUM * 6);
item = [[SearchResultItem alloc] init];
item.data = [data objectAtIndex:i];
item.view.userInteractionEnabled = YES;
if(j % 2 == 0 && j != 0)
{
yCounter = 0;
xCounter++;
} else if(j % 2 == 1) {
yCounter = 1;
}
item.view.frame = CGRectMake(14.5 + (xCounter * 344.25),
0 + ((item.view.frame.size.height + 10) * yCounter),
item.view.frame.size.width,
item.view.frame.size.height);
[arr addObject:item];
[ret addSubview:item.view];
}
[contents setObject:arr forKey:[NSString stringWithFormat:@"arr_%i", currentPageNUM]];
[arr release];
return ret;
Dodawanie widoku do scroll'a:
cont = [self buildView:0];
[scroll addSubview:cont];
w klasie SearchResultItem znajduja sie dwa przyciski ktore nie dzialaja
Łukasz Szyszkowski edytował(a) ten post dnia 21.02.11 o godzinie 10:24