我正在创建一个应用程序,该应用程序使用滚动图像的 UIScrollView 和加载新 View 并允许新图像层(有点像 Photoshop 分层)的分段控件 - 出于某种原因,当我单击该层时,它记住该位置但创建一个新图层.... 我怎样才能阻止这种情况发生,所以一旦选择了图层并选择了图像,当用户返回时,它会转到最后加载的位置?
另外,作为附带的事情...当 UIScrollView 加载时,我不能使用我的手势识别或 UIAlertView?有谁知道为什么?
这是我的代码....提前致谢
- layerControlNSInteger)index
{
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = 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.view addSubview:scroll];
[scroll release];
switch (index)
{
case 0: scroll = self.scroll1;
case 1: scroll = self.scroll2;
case 2: scroll = self.scroll3;
case 4: scroll = self.scroll4;
case 5: scroll = self.scroll5;
}
/* if (scroll == nil)
{
[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = 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.view addSubview:scroll];
[scroll autorelease]; */
}
}
//Method to add a filter to the page
- (void)addFilterid)sender
{
UISegmentedControl *filterController = (UISegmentedControl *)sender;
[self layerControl:[filterController selectedSegmentIndex]];
}
- (UIImage*)saveImages
{
UIImage *image = [UIImage imageNamed"UrbanPhoto##1"];
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
尝试在用户操作之前保存 UIScrollView.contentOffset
的值,然后在操作完成后恢复该值。
关于iphone - 保存并加载 UIScrollView 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8205740/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |