mirror of
https://github.com/zhigang1992/MultiLayerNavigation.git
synced 2026-01-12 22:49:04 +08:00
using gesture to drag
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
//
|
||||
// MLScrollView.h
|
||||
// MultiLayerNavigation
|
||||
//
|
||||
// Created by Feather Chan on 13-4-12.
|
||||
// Copyright (c) 2013年 Feather Chan. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MLScrollView : UIScrollView
|
||||
|
||||
@end
|
||||
@@ -1,112 +0,0 @@
|
||||
//
|
||||
// MLScrollView.m
|
||||
// MultiLayerNavigation
|
||||
//
|
||||
// Created by Feather Chan on 13-4-12.
|
||||
// Copyright (c) 2013年 Feather Chan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MLScrollView.h"
|
||||
#import "MLNavigationController.h"
|
||||
|
||||
|
||||
@interface UIView (FindUIViewController)
|
||||
|
||||
- (UIViewController *)viewController;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation MLScrollView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (MLNavigationController *)firstAvailableNavigationController
|
||||
{
|
||||
if ([[self viewController].navigationController isKindOfClass:[MLNavigationController class]])
|
||||
{
|
||||
return (MLNavigationController *)[self viewController].navigationController;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - UIResponse Subclassing -
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
|
||||
//send the event to MLNavigationController
|
||||
[self.firstAvailableNavigationController touchesBegan:touches withEvent:event];
|
||||
|
||||
self.scrollEnabled = NO;
|
||||
}
|
||||
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesMoved:touches withEvent:event];
|
||||
|
||||
[self.firstAvailableNavigationController touchesMoved:touches withEvent:event];
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesEnded:touches withEvent:event];
|
||||
|
||||
[self.firstAvailableNavigationController touchesEnded:touches withEvent:event];
|
||||
|
||||
self.scrollEnabled = YES;
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesCancelled:touches withEvent:event];
|
||||
|
||||
[self.firstAvailableNavigationController touchesCancelled:touches withEvent:event];
|
||||
|
||||
self.scrollEnabled = YES;
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation UIView (FindUIViewController)
|
||||
|
||||
// Get to UIViewController from UIView on iPhone?
|
||||
// http://stackoverflow.com/a/3732812/1104158
|
||||
|
||||
|
||||
- (UIViewController *)viewController {
|
||||
/// Finds the view's view controller.
|
||||
|
||||
// Traverse responder chain. Return first found view controller, which will be the view's view controller.
|
||||
UIResponder *responder = self;
|
||||
while ((responder = [responder nextResponder]))
|
||||
if ([responder isKindOfClass: [UIViewController class]])
|
||||
return (UIViewController *)responder;
|
||||
|
||||
// If the view controller isn't found, return nil.
|
||||
return nil;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
//
|
||||
// MLTableView.h
|
||||
// MultiLayerNavigation
|
||||
//
|
||||
// Created by Feather Chan on 13-4-17.
|
||||
// Copyright (c) 2013年 Feather Chan. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MLTableView : UITableView
|
||||
|
||||
@end
|
||||
@@ -1,104 +0,0 @@
|
||||
//
|
||||
// MLTableView.m
|
||||
// MultiLayerNavigation
|
||||
//
|
||||
// Created by Feather Chan on 13-4-17.
|
||||
// Copyright (c) 2013年 Feather Chan. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MLTableView.h"
|
||||
#import "MLNavigationController.h"
|
||||
|
||||
@implementation MLTableView
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - UIResponse Subclassing -
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
|
||||
//send the event to MLNavigationController
|
||||
[self.firstAvailableNavigationController touchesBegan:touches withEvent:event];
|
||||
|
||||
self.scrollEnabled = NO;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesMoved:touches withEvent:event];
|
||||
|
||||
[self.firstAvailableNavigationController touchesMoved:touches withEvent:event];
|
||||
|
||||
self.allowsSelection = NO;
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesEnded:touches withEvent:event];
|
||||
|
||||
[self.firstAvailableNavigationController touchesEnded:touches withEvent:event];
|
||||
|
||||
self.scrollEnabled = YES;
|
||||
self.allowsSelection = YES;
|
||||
[self deselectRowAtIndexPath:[self indexPathForSelectedRow] animated:NO];
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[super touchesCancelled:touches withEvent:event];
|
||||
|
||||
[self.firstAvailableNavigationController touchesCancelled:touches withEvent:event];
|
||||
|
||||
self.scrollEnabled = YES;
|
||||
self.allowsSelection = YES;
|
||||
[self deselectRowAtIndexPath:[self indexPathForSelectedRow] animated:NO];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
- (MLNavigationController *)firstAvailableNavigationController
|
||||
{
|
||||
if ([[self viewController].navigationController isKindOfClass:[MLNavigationController class]])
|
||||
{
|
||||
return (MLNavigationController *)[self viewController].navigationController;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIViewController *)viewController {
|
||||
/// Finds the view's view controller.
|
||||
|
||||
// Traverse responder chain. Return first found view controller, which will be the view's view controller.
|
||||
UIResponder *responder = self;
|
||||
while ((responder = [responder nextResponder]))
|
||||
if ([responder isKindOfClass: [UIViewController class]])
|
||||
return (UIViewController *)responder;
|
||||
|
||||
// If the view controller isn't found, return nil.
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user