1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// 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