Я пытаюсь разработать это приложение, и мне действительно тяжело.Я пытаюсь использовать UISegmentedControl для загрузки набора UIScrollViews, которые действуют как фильтры изображений.
Помимо огромных проблем с UIScrollViews (именно поэтому по какой-то причине новый создается индивидуально в каждом сегменте)щелчок по сегменту 1 загружает все 6 UIScrollViews и позволяет мне прокручивать только первый.Когда я выбираю последний сегмент, загружается только 1 UIScrollView ...
Я действительно не знаю, что я делаю не так, поэтому любые предложения будут великолепны!
Большое спасибо,
Лоуренс
~~~~ Код ниже ~~~
- (void)layerSelected:(id)sender
{
int index = filterControl.selectedSegmentIndex;
switch (index)
{
case 0: if (scroll == nil)
{
scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = YES;
scroll.delaysContentTouches = NO;
scroll.userInteractionEnabled = YES;
NSInteger viewCount = 15;
for (int i = 0; i < viewCount; i++)
{
CGFloat yOrigin = i * self.view.frame.size.width;
UIImageView *filterViewOverlay = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
[filterViewOverlay setImage:[filterManager objectAtIndex:i]];
[scroll addSubview:filterViewOverlay];
[filterViewOverlay release];
}
scroll.contentSize = CGSizeMake(self.view.frame.size.width * viewCount, self.view.frame.size.height);
[self.scroll setContentOffset:currentPos1];
[self.view addSubview:scroll];
[scroll release];
}
else
{
//Set the position to the correct one
}
case 1: if (scroll1 == nil)
{
scroll1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll1.pagingEnabled = YES;
scroll1.delaysContentTouches = NO;
scroll1.userInteractionEnabled = YES;
NSInteger viewCount = 15;
for (int i = 0; i < viewCount; i++)
{
CGFloat yOrigin = i * self.view.frame.size.width;
UIImageView *filterViewOverlay = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
[filterViewOverlay setImage:[filterManager objectAtIndex:i]];
[scroll1 addSubview:filterViewOverlay];
[filterViewOverlay release];
}
scroll1.contentSize = CGSizeMake(self.view.frame.size.width * viewCount, self.view.frame.size.height);
[self.scroll1 setContentOffset:currentPos2];
[self.view addSubview:scroll1];
[scroll1 release];
}
else
{
//Set the position to the correct one
}
case 2: if (scroll2 == nil)
{
scroll2 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll2.pagingEnabled = YES;
scroll2.delaysContentTouches = NO;
scroll2.userInteractionEnabled = YES;
NSInteger viewCount = 15;
for (int i = 0; i < viewCount; i++)
{
CGFloat yOrigin = i * self.view.frame.size.width;
UIImageView *filterViewOverlay = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
[filterViewOverlay setImage:[filterManager objectAtIndex:i]];
[scroll2 addSubview:filterViewOverlay];
[filterViewOverlay release];
}
scroll2.contentSize = CGSizeMake(self.view.frame.size.width * viewCount, self.view.frame.size.height);
[self.scroll2 setContentOffset:currentPos3];
[self.view addSubview:scroll2];
[scroll2 release];
}
else
{
//Set the position to the correct one
}
case 3: if (scroll3 == nil)
{
scroll3 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll3.pagingEnabled = YES;
scroll3.delaysContentTouches = NO;
scroll3.userInteractionEnabled = YES;
NSInteger viewCount = 15;
for (int i = 0; i < viewCount; i++)
{
CGFloat yOrigin = i * self.view.frame.size.width;
UIImageView *filterViewOverlay = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
[filterViewOverlay setImage:[filterManager objectAtIndex:i]];
[scroll3 addSubview:filterViewOverlay];
[filterViewOverlay release];
}
scroll3.contentSize = CGSizeMake(self.view.frame.size.width * viewCount, self.view.frame.size.height);
[self.scroll3 setContentOffset:currentPos4];
[self.view addSubview:scroll3];
[scroll3 release];
}
else
{
//Set the position to the correct one
}
case 4: if (scroll4 == nil)
{
scroll4 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll4.pagingEnabled = YES;
scroll4.delaysContentTouches = NO;
scroll4.userInteractionEnabled = YES;
NSInteger viewCount = 15;
for (int i = 0; i < viewCount; i++)
{
CGFloat yOrigin = i * self.view.frame.size.width;
UIImageView *filterViewOverlay = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
[filterViewOverlay setImage:[filterManager objectAtIndex:i]];
[scroll4 addSubview:filterViewOverlay];
[filterViewOverlay release];
}
scroll4.contentSize = CGSizeMake(self.view.frame.size.width * viewCount, self.view.frame.size.height);
[self.scroll4 setContentOffset:currentPos5];
[self.view addSubview:scroll4];
[scroll4 release];
}
else
{
//Set the position to the correct one
}
case 5: if (scroll5 == nil)
{
scroll5 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll5.pagingEnabled = YES;
scroll5.delaysContentTouches = NO;
scroll5.userInteractionEnabled = YES;
NSInteger viewCount = 15;
for (int i = 0; i < viewCount; i++)
{
CGFloat yOrigin = i * self.view.frame.size.width;
UIImageView *filterViewOverlay = [[UIImageView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
[filterViewOverlay setImage:[filterManager objectAtIndex:i]];
[scroll5 addSubview:filterViewOverlay];
[filterViewOverlay release];
}
scroll5.contentSize = CGSizeMake(self.view.frame.size.width * viewCount, self.view.frame.size.height);
[self.scroll5 setContentOffset:currentPos6];
[self.view addSubview:scroll5];
[scroll5 release];
}
else
{
//Set the position to the correct one
}
}
}