// // SVerticalView.m // SVInSVDemo // // Created by loufq on 12-4-27. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. // #import "SVerticalView.h" @implementation SVerticalView @synthesize ds,curIndex; - (void)dealloc { // self.ds = nil; } - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { _myPV=[[ATPagingView alloc] initWithFrame:frame]; _myPV.direction = ATPagingViewVertical; _myPV.delegate = self; [self addSubview:_myPV]; } return self; } - (NSInteger)numberOfPagesInPagingView:(ATPagingView *)pagingView{ return self.ds.count; } -(void)setDs:(NSArray *)aDS{ if (ds!=aDS) { ds =aDS; } [_myPV reloadData]; _myPV.currentPageIndex = 0; } -(void)setCurIndex:(int)aCurIndex{ curIndex = aCurIndex; [_myPV reloadData]; _myPV.currentPageIndex = curIndex; } - (UIView *)viewForPageInPagingView:(ATPagingView *)pagingView atIndex:(NSInteger)index{ // UIImageView* iv =(UIImageView*)[pagingView dequeueReusablePage]; // if (!iv) { // iv =[[UIImageView alloc] initWithFrame:pagingView.frame]; // } // NSString* path = [self.ds objectAtIndex:index]; // iv.image = [UIImage imageWithContentsOfFile:path]; // return iv; UIView *uiview = [pagingView dequeueReusablePage]; if(!uiview){ uiview = [[UIView alloc] initWithFrame:pagingView.frame]; } uiview = [self.ds objectAtIndex:index]; return uiview; } - (void)currentPageDidChangeInPagingView:(ATPagingView *)pagingView{ NSLog(@"SVerticalView"); if (self.delegate != nil) { [self.delegate kwm_getSVerticalViewCurrnetPage:pagingView.currentPageIndex]; } } @end