Skip to content

Commit

Permalink
Add sentinel to disable UICollectionView forwarding if class exists
Browse files Browse the repository at this point in the history
  • Loading branch information
steipete committed Sep 1, 2013
1 parent d6f267f commit f90f138
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions PSTCollectionView/PSTCollectionView.h
Expand Up @@ -34,11 +34,11 @@ typedef NS_ENUM(NSUInteger, PSTCollectionElementCategory) {
PSTCollectionElementCategoryDecorationView
};

/**
Replacement for UICollectionView for iOS4/5.
Only supports a subset of the features of UICollectionView.
e.g. animations won't be handled.
*/
/// Define the `PSTCollectionViewDisableForwardToUICollectionViewSentinel` to disable the automatic forwarding to UICollectionView on iOS 6+. (Copy below line into your AppDelegate.m)
//@interface PSTCollectionViewDisableForwardToUICollectionViewSentinel : NSObject @end @implementation PSTCollectionViewDisableForwardToUICollectionViewSentinel @end

/// API-compatible replacement for UICollectionView.
/// Works on iOS 4.3 upwards (including iOS 6).
@interface PSTCollectionView : UIScrollView

- (id)initWithFrame:(CGRect)frame collectionViewLayout:(PSTCollectionViewLayout *)layout; // the designated initializer
Expand Down
2 changes: 2 additions & 0 deletions PSTCollectionView/PSTCollectionView.m
Expand Up @@ -2255,6 +2255,8 @@ static BOOL PSTRegisterClass(NSString *UIClassName, Class PSTClass) {

// Create subclasses that pose as UICollectionView et al, if not available at runtime.
__attribute__((constructor)) static void PSTCreateUICollectionViewClasses(void) {
if (objc_getClass("PSTCollectionViewDisableForwardToUICollectionViewSentinel")) return;

@autoreleasepool {
// Change superclass at runtime. This allows seamless switching from PST* to UI* at runtime.
PSTRegisterClass(@"UICollectionView", PSUICollectionView_.class);
Expand Down

0 comments on commit f90f138

Please sign in to comment.