Skip to content

Commit aedf93b

Browse files
committed
更新到0.5.1
1 parent f784494 commit aedf93b

File tree

5 files changed

+39
-34
lines changed

5 files changed

+39
-34
lines changed

Demo/Demo/RootVC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
NSMutableArray *viewsArray; //视图数组
1515

16-
NSArray *textArray; //文本数组
16+
NSArray *textsArray; //文本数组
1717
}
1818

1919
@end

Demo/Demo/RootVC.m

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ - (void)viewDidLoad
3232

3333
//视图背景颜色的数组
3434
NSArray *colorArray = @[[UIColor cyanColor], [UIColor blueColor], [UIColor greenColor], [UIColor yellowColor], [UIColor purpleColor]];
35-
textArray = @[@"0", @"1", @"2", @"3", @"4"];
35+
textsArray = @[@"0", @"1", @"2", @"3", @"4"];
3636

3737
//遍历视图
3838
for (int i = 0; i < colorArray.count; ++i) {
@@ -46,28 +46,33 @@ - (void)viewDidLoad
4646

4747
//轮播图的背景
4848
carouselView.backgroundColor = [[UIColor purpleColor] colorWithAlphaComponent:0.1];
49-
/*
50-
//设置页数
51-
[carouselView numberOfPagesUsingBlock:^NSInteger(PFCarouselView *carouselView){
52-
return 5;
53-
}];
54-
55-
//设置视图
56-
[carouselView setupContentViewUsingBlock:^UIView *(PFCarouselView *carouselView, NSInteger index) {
57-
return viewsArray[index];
58-
}];
59-
60-
//设置文本
61-
[carouselView resetTextLabelUsingBlock:^void (PFCarouselView *carouselView, UILabel *textLabel, NSInteger index) {
62-
textLabel.text = textArray[index];
63-
NSLog(@"%d", index);
64-
}];
65-
66-
//设置点击事件
67-
[carouselView didSelectViewUsingBlock:^(PFCarouselView *carouselView, NSInteger index) {
68-
NSLog(@"点击了第%d个", index);
69-
}];
70-
*/
49+
/*
50+
//设置页数
51+
@weakify(viewsArray)
52+
[carouselView numberOfPagesUsingBlock:^NSInteger(PFCarouselView *carouselView){
53+
@strongify(viewsArray)
54+
return strong_viewsArray.count;
55+
}];
56+
57+
//设置视图
58+
[carouselView setupContentViewUsingBlock:^UIView *(PFCarouselView *carouselView, NSInteger index) {
59+
@strongify(viewsArray)
60+
return strong_viewsArray[index];
61+
}];
62+
63+
//设置文本
64+
@weakify(textsArray)
65+
[carouselView resetTextLabelUsingBlock:^void (PFCarouselView *carouselView, UILabel *textLabel, NSInteger index) {
66+
@strongify(textsArray)
67+
textLabel.text = strong_textsArray[index];
68+
NSLog(@"%d", index);
69+
}];
70+
71+
//设置点击事件
72+
[carouselView didSelectViewUsingBlock:^(PFCarouselView *carouselView, NSInteger index) {
73+
NSLog(@"点击了第%d个", index);
74+
}];
75+
*/
7176
[self.view addSubview:carouselView];
7277
}
7378

@@ -76,7 +81,7 @@ - (void)viewDidLoad
7681
//设置页数
7782
- (NSInteger)numberOfPagesInCarouselView:(PFCarouselView *)automaticScrollView
7883
{
79-
return 5;
84+
return viewsArray.count;
8085
}
8186

8287
//设置视图
@@ -88,7 +93,7 @@ - (UIView *)carouselView:(PFCarouselView *)carouselView setupContentViewAtIndex:
8893
//设置文本
8994
- (void)carouselView:(PFCarouselView *)carouselView resetTextLabel:(UILabel *)textLabel atIndex:(NSInteger)index
9095
{
91-
textLabel.text = textArray[index];
96+
textLabel.text = textsArray[index];
9297
}
9398

9499
//设置点击事件

PFCarouselView/PFCarouselView.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// https://github.com/PFei-He/PFCarouselView
99
//
10-
// vesion: 0.5.1-beta5
10+
// vesion: 0.5.1
1111
//
1212
// Permission is hereby granted, free of charge, to any person obtaining a copy
1313
// of this software and associated documentation files (the "Software"), to deal
@@ -66,25 +66,25 @@
6666
* 强弱引用转换,用于解决代码块(block)与强引用对象之间的循环引用问题
6767
* 调用方式: `@weakify(object)`实现弱引用转换,`@strongify(object)`实现强引用转换
6868
*
69-
* 示例:
69+
* 示例
7070
* @weakify(object)
7171
* [obj block:^{
7272
* @strongify(object)
73-
* object = something;
73+
* strong_object = something;
7474
* }];
7575
*/
7676
#ifndef weakify
7777
#if __has_feature(objc_arc)
78-
#define weakify(object) autoreleasepool{} __weak __typeof__(object) __weak_##x##__ = x;
78+
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
7979
#else
80-
#define weakify(object) autoreleasepool{} __block __typeof__(object) __block_##x##__ = x;
80+
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
8181
#endif
8282
#endif
8383
#ifndef strongify
8484
#if __has_feature(objc_arc)
85-
#define strongify(object) try{} @finally{} __typeof__(object) x = __weak_##x##__;
85+
#define strongify(object) try{} @finally{} __typeof__(object) strong##_##object = weak##_##object;
8686
#else
87-
#define strongify(object) try{} @finally{} __typeof__(object) x = __block_##x##__;
87+
#define strongify(object) try{} @finally{} __typeof__(object) strong##_##object = block##_##object;
8888
#endif
8989
#endif
9090

PFCarouselView/PFCarouselView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// https://github.com/PFei-He/PFCarouselView
99
//
10-
// vesion: 0.5.1-beta5
10+
// vesion: 0.5.1
1111
//
1212
// Permission is hereby granted, free of charge, to any person obtaining a copy
1313
// of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)