Skip to content

Commit

Permalink
Updated to version 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Feb 3, 2014
1 parent 568d446 commit 522b867
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 42 deletions.
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SwipeView

Version 1.3, September 7th, 2013
Version 1.3, February 3rd, 2014

Copyright (C) 2010 Charcoal Design

Expand Down
6 changes: 4 additions & 2 deletions RELEASE NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version 1.3 beta
Version 1.3

- SwipeView now requires ARC (see README for details)
- Added autoscroll property to set SwipeView scrolling at a constant speed
Expand All @@ -8,7 +8,9 @@ Version 1.3 beta
- Added scrollByOffset:duration: and scrollToOffset:duration: methods
- Calling reloadData no longer resets scroll position
- No longer behaves strangely if there is only one item and wrap is enabled
- Now conforms to -Wextra warning level
- Fixed problems with contentOffset when used inside UINavigationController
- You can now toggle wrapEnabled at any time without messing up item views
- Now conforms to -Weverything warning level

Version 1.2.10

Expand Down
6 changes: 3 additions & 3 deletions SwipeView.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = "SwipeView"
s.version = "1.2.10"
s.version = "1.3"
s.summary = "Horizontal, paged scrolling views based on UIScrollView, with convenient functionality in UITableView-style."
s.description = "SwipeView is a class designed to simplify the implementation of horizontal, paged scrolling views on iOS. It is based on a UIScrollView, but adds convenient functionality such as a UITableView-style dataSource/delegate interface and efficient view loading, unloading and recycling."
s.homepage = "https://github.com/nicklockwood/SwipeView"
s.license = { :type => 'MIT', :file => 'LICENCE.md' }
s.license = { :type => 'zlib', :file => 'LICENCE.md' }
s.author = { "Nick Lockwood" => "[email protected]" }
s.source = { :git => "https://github.com/nicklockwood/SwipeView.git", :tag => "1.2.10" }
s.source = { :git => "https://github.com/nicklockwood/SwipeView.git", :tag => "1.3" }
s.source_files = 'SwipeView'
s.requires_arc = true
s.platform = :ios
Expand Down
11 changes: 10 additions & 1 deletion SwipeView/SwipeView.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// SwipeView.h
//
// Version 1.3 beta 8
// Version 1.3
//
// Created by Nick Lockwood on 03/09/2010.
// Copyright 2010 Charcoal Design
Expand Down Expand Up @@ -31,6 +31,11 @@
//


#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wauto-import"
#pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis"


#import <Availability.h>
#undef weak_delegate
#if __has_feature(objc_arc) && __has_feature(objc_arc_weak)
Expand Down Expand Up @@ -119,3 +124,7 @@ SwipeViewAlignment;
- (void)swipeView:(SwipeView *)swipeView didSelectItemAtIndex:(NSInteger)index;

@end


#pragma GCC diagnostic pop

47 changes: 36 additions & 11 deletions SwipeView/SwipeView.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// SwipeView.m
//
// Version 1.3 beta 8
// Version 1.3
//
// Created by Nick Lockwood on 03/09/2010.
// Copyright 2010 Charcoal Design
Expand Down Expand Up @@ -35,6 +35,14 @@
#import <objc/message.h>


#pragma GCC diagnostic ignored "-Wdirect-ivar-access"
#pragma GCC diagnostic ignored "-Warc-repeated-use-of-weak"
#pragma GCC diagnostic ignored "-Wreceiver-is-weak"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wselector"
#pragma GCC diagnostic ignored "-Wgnu"


#import <Availability.h>
#if !__has_feature(objc_arc)
#error This class requires automatic reference counting
Expand Down Expand Up @@ -228,9 +236,12 @@ - (void)setWrapEnabled:(BOOL)wrapEnabled
{
if (_wrapEnabled != wrapEnabled)
{
CGFloat previousOffset = [self clampedOffset:_scrollOffset];
_wrapEnabled = wrapEnabled;
_scrollView.bounces = _bounces && !_wrapEnabled;
[self setNeedsLayout];
[self layoutIfNeeded];
self.scrollOffset = previousOffset;
}
}

Expand All @@ -253,7 +264,7 @@ - (void)setBounces:(BOOL)bounces

- (void)setDecelerationRate:(float)decelerationRate
{
if (_decelerationRate != decelerationRate)
if (fabsf(_decelerationRate - decelerationRate) > 0.0001f)
{
_decelerationRate = decelerationRate;
_scrollView.decelerationRate = _decelerationRate;
Expand All @@ -262,7 +273,7 @@ - (void)setDecelerationRate:(float)decelerationRate

- (void)setAutoscroll:(CGFloat)autoscroll
{
if (_autoscroll != autoscroll)
if (fabsf(_autoscroll - autoscroll) > 0.0001f)
{
_autoscroll = autoscroll;
if (autoscroll) [self startAnimation];
Expand Down Expand Up @@ -317,7 +328,7 @@ - (UIView *)currentItemView

- (NSInteger)indexOfItemView:(UIView *)view
{
NSInteger index = [[_itemViews allValues] indexOfObject:view];
NSUInteger index = [[_itemViews allValues] indexOfObject:view];
if (index != NSNotFound)
{
return [[_itemViews allKeys][index] integerValue];
Expand Down Expand Up @@ -380,12 +391,30 @@ - (void)updateScrollOffset
_scrollOffset = [self clampedOffset:_scrollOffset];
}
}
if (_vertical && fabsf(_scrollView.contentOffset.x) > 0.0001f)
{
[self setContentOffsetWithoutEvent:CGPointMake(0.0f, _scrollView.contentOffset.y)];
}
else if (!_vertical && fabsf(_scrollView.contentOffset.y) > 0.0001f)
{
[self setContentOffsetWithoutEvent:CGPointMake(_scrollView.contentOffset.x, 0.0f)];
}
}

- (void)updateScrollViewDimensions
{
CGRect frame = self.bounds;
CGSize contentSize = frame.size;

if (_vertical)
{
contentSize.width -= (_scrollView.contentInset.left + _scrollView.contentInset.right);
}
else
{
contentSize.height -= (_scrollView.contentInset.top + _scrollView.contentInset.bottom);
}

switch (_alignment)
{
case SwipeViewAlignmentCenter:
Expand Down Expand Up @@ -418,10 +447,6 @@ - (void)updateScrollViewDimensions
}
break;
}
default:
{
break;
}
}

if (_wrapEnabled)
Expand Down Expand Up @@ -620,7 +645,7 @@ - (void)step
if (_scrolling)
{
NSTimeInterval time = fminf(1.0f, (currentTime - _startTime) / _scrollDuration);
CGFloat delta = [self easeInOut:time];
delta = [self easeInOut:time];
_scrollOffset = [self clampedOffset:_startOffset + (_endOffset - _startOffset) * delta];
if (_vertical)
{
Expand Down Expand Up @@ -769,7 +794,7 @@ - (void)setCurrentPage:(NSInteger)currentPage

- (void)setScrollOffset:(CGFloat)scrollOffset
{
if (_scrollOffset != scrollOffset)
if (fabsf(_scrollOffset - scrollOffset) > 0.0001f)
{
_scrollOffset = scrollOffset;
_lastUpdateOffset = _scrollOffset - 1.0f; //force refresh
Expand Down Expand Up @@ -1172,4 +1197,4 @@ - (void)scrollViewDidEndDecelerating:(__unused UIScrollView *)scrollView
[_delegate swipeViewDidEndDecelerating:self];
}

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,22 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_OBJC_RECEIVER_WEAK = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -227,20 +239,39 @@
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
WARNING_CFLAGS = "-Wall";
WARNING_CFLAGS = (
"-Weverything",
"-Wno-objc-missing-property-synthesis",
);
};
name = Debug;
};
Expand All @@ -250,28 +281,59 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_OBJC_RECEIVER_WEAK = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
WARNING_CFLAGS = "-Wall";
WARNING_CFLAGS = (
"-Weverything",
"-Wno-objc-missing-property-synthesis",
);
};
name = Release;
};
Expand All @@ -284,10 +346,6 @@
INFOPLIST_FILE = "SwipeViewExample/SwipeViewExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WARNING_CFLAGS = (
"-Wall",
"-Wextra",
);
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -301,10 +359,6 @@
INFOPLIST_FILE = "SwipeViewExample/SwipeViewExample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WARNING_CFLAGS = (
"-Wall",
"-Wextra",
);
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
self.viewController = [[ViewController alloc] init];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window makeKeyAndVisible];
return YES;
}
Expand Down
File renamed without changes
Loading

0 comments on commit 522b867

Please sign in to comment.