Ios4 基于UIScrollView的图像库在图像顶部获得白色间隙
基于UIScrollView的图像库在图像顶部获得白色间隙,图像被向下推一点。如何删除空白Ios4 基于UIScrollView的图像库在图像顶部获得白色间隙,ios4,uiscrollview,Ios4,Uiscrollview,基于UIScrollView的图像库在图像顶部获得白色间隙,图像被向下推一点。如何删除空白 @implementation PagerViewController - (void) setImages:(NSArray *) images { if(imageSet) [imageSet release]; imageSet = [images retain]; view1.frame = CGRectMake(0,0,320,480); view2.fra
@implementation PagerViewController
- (void) setImages:(NSArray *) images
{
if(imageSet) [imageSet release];
imageSet = [images retain];
view1.frame = CGRectMake(0,0,320,480);
view2.frame = CGRectMake(320,0,320,480);
view1.image = [imageSet objectAtIndex:0];
view2.image = [imageSet objectAtIndex:1];
scroll.contentSize = CGSizeMake([imageSet count]*320,480);
}
- (id) init
{
if(self = [super init])
{
scroll = [[UIScrollView alloc] init];
scroll.scrollEnabled = YES;
scroll.pagingEnabled = YES;
scroll.directionalLockEnabled = YES;
scroll.showsVerticalScrollIndicator = NO;
scroll.showsHorizontalScrollIndicator = NO;
scroll.delegate = self;
scroll.backgroundColor = [UIColor clearColor];
scroll.autoresizesSubviews = YES;
scroll.frame = CGRectMake(0,0,320,480);
[self.view addSubview:scroll];
view1 = [[UIImageView alloc] init];
[scroll addSubview:view1];
view2 = [[UIImageView alloc] init];
[scroll addSubview:view2];
}
return self;
}
- (void) update
{
CGFloat pageWidth =320;
float currPos = scroll.contentOffset.x;
int selectedPage = roundf(currPos / pageWidth);
float truePosition = selectedPage*pageWidth;
int zone = selectedPage % 2;
BOOL view1Active = zone == 0;
UIImageView *nextView = view1Active ? view2 : view1;
int nextpage = truePosition > currPos ? selectedPage-1 : selectedPage+1;
if(nextpage >= 0 && nextpage < [imageSet count])
{
if((view1Active && nextpage == view1Index) || (!view1Active && nextpage == view2Index)) return;
NSLog(@"Load next image!");
nextView.frame = CGRectMake(nextpage*320,0,320,480);
nextView.image = [imageSet objectAtIndex:nextpage];
if(view1Active) view1Index = nextpage;
else view2Index = nextpage;
}
}
@implementation-PagerViewController
-(void)设置图像:(NSArray*)图像
{
if(图像集)[图像集发布];
图像集=[图像保留];
view1.frame=CGRectMake(0,0320480);
view2.frame=CGRectMake(320,0320480);
view1.image=[imageSet objectAtIndex:0];
view2.image=[imageSet objectAtIndex:1];
scroll.contentSize=CGSizeMake([imageSet count]*320480);
}
-(id)init
{
if(self=[super init])
{
滚动=[[UIScrollView alloc]init];
scroll.scrollEnabled=是;
scroll.paginEnabled=是;
scroll.directionalLockEnabled=是;
scroll.showsVerticalScrollIndicator=否;
scroll.showshorizontalscrolindicator=否;
scroll.delegate=self;
scroll.backgroundColor=[UIColor clearColor];
scroll.autoresizesSubviews=YES;
scroll.frame=CGRectMake(0,0320480);
[self.view addSubview:滚动];
view1=[[UIImageView alloc]init];
[滚动添加子视图:视图1];
view2=[[UIImageView alloc]init];
[滚动添加子视图:视图2];
}
回归自我;
}
-(作废)更新
{
CGFloat pageWidth=320;
float currPos=scroll.contentOffset.x;
int selectedPage=roundf(currPos/pageWidth);
float truePosition=所选页面*页面宽度;
int zone=selectedPage%2;
BOOL view1活动=区域==0;
UIImageView*nextView=view1活动?view2:view1;
int nextpage=truePosition>currPos?selectedPage-1:selectedPage+1;
如果(下一页>=0&&下一页<[imageSet计数])
{
如果((view1Active&nextpage==view1Index)| |(!view1Active&nextpage==view2Index))返回;
NSLog(@“加载下一个图像!”);
nextView.frame=CGRectMake(nextpage*320,0320480);
nextView.image=[imageSet objectAtIndex:nextpage];
如果(视图1活动)视图1索引=下一页;
else VIEW2索引=下一页;
}
}
在.plist文件中编辑的“状态栏最初隐藏-选中”解决了它