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
72
73
74
75
76
77
78
//
// SHorizontalView.m
// SVInSVDemo
//
// Created by loufq on 12-4-27.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#import "SHorizontalView.h"
@implementation SHorizontalView
@synthesize ds,curIndexPath;
- (void)dealloc {
// self.curIndexPath = nil;
// self.ds = nil;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
myPV=[[ATPagingView alloc] initWithFrame:frame];
myPV.delegate = self;
[self addSubview:myPV];
}
return self;
}
-(void)setDs:(NSArray *)aDS{
if (ds!=aDS) {
ds =aDS;
}
[myPV reloadData];
myPV.currentPageIndex = 0;
}
- (NSInteger)numberOfPagesInPagingView:(ATPagingView *)pagingView{
return self.ds.count;
}
- (UIView *)viewForPageInPagingView:(ATPagingView *)pagingView atIndex:(NSInteger)index{
SVerticalView* svv =(SVerticalView*)[pagingView dequeueReusablePage];
if (!svv) {
svv =[[SVerticalView alloc] initWithFrame:pagingView.frame];
}
NSArray* dsChild =[self.ds objectAtIndex:index];
svv.ds = dsChild;
svv.delegate = self;
return svv;
}
-(void)setCurIndexPath:(NSIndexPath *)aCurIndexPath{
curIndexPath = aCurIndexPath;
myPV.currentPageIndex = aCurIndexPath.section;
[self performSelector:@selector(delayOper) withObject:nil afterDelay:0.1];
}
-(void)delayOper{
SVerticalView* svv = (SVerticalView*)[myPV viewForPageAtIndex:myPV.currentPageIndex];
if(svv != nil){
svv.curIndex = curIndexPath.row;
}
}
- (void)kwm_getSVerticalViewCurrnetPage:(NSInteger)currentPage{
NSLog(@"SHorizontalView ");
if (self.delegate != nil) {
[self.delegate kwm_getSHorizontalViewCurrnetPage:currentPage];
}
}
@end