chavezchen / cwlateralslide Goto Github PK
View Code? Open in Web Editor NEWOne line of code to integrate 0 coupling side drawer!一行代码集成0耦合侧滑抽屉!
License: MIT License
One line of code to integrate 0 coupling side drawer!一行代码集成0耦合侧滑抽屉!
License: MIT License
1,首页添加了个跑马灯效果,内部是使用UIView动画或者基础动画实现,
和抽屉的动画冲突了.
因为跑马灯暂停时,是通过修改layer层的属性,
是不是线程堵塞了,
只要触发侧滑手势,跑马灯就消失,松手就有了.
一时不知道怎么解决了.
我想在左侧栏的某个按钮的响应事件中,收回侧边栏,并发一个通知给首页,让首页弹出一个view,[[NSNotificationCenter defaultCenter] postNotificationName:@"showLogin" object:nil];
[self dismissViewControllerAnimated:YES completion:nil]; 这是按钮中的代码,在首页可以收到通知,但是view弹不出来,这是什么情况?
你好,在iPhone 6上,
开启右滑出抽屉,
反复十次,
就会出现卡顿的情况.
但是,点击按钮弹出侧滑很流畅.点击消失也很流畅,但是侧滑消失也卡顿.
我在界面加了tableview 添加了cell侧滑 注册了侧边栏侧滑手势 cell 侧滑就不起作用了
加油
swift里用这个框架,push后不想坐着Demo里那样直接跳到要Push的目标控制器,而是先回到最开始的控制器,再从最开始的控制器push到目标控制器,希望作者能看看
大神,当我使用覆盖在上面左右侧滑出时,横竖屏切换时会有问题,我设置contview的autoresizingMask没有效果,请问我该如何解决呢?
你好,我的首页是一个tableViewController,注册手势驱动之后,tableview就无法滚动了,请问是什么原因啊
如题,为什么呢?就弹出个左菜单,能不触发吗?
LeftViewController点解cell主动关闭,调用方法 [self dismissViewControllerAnimated:YES completion:nil];有延迟的情况,请问需要如何解决
抽屉出现点击抽屉菜单push或者挑战到Next界面,返回的时候抽屉消失了,怎么让抽屉不消失?
而且还有个问题,demo中,用 [self cw_showDrawerViewController:vc animationType:CWDrawerAnimationTypeMask configuration:nil]; present 到LeftVC 之后 再用 [self cw_pushViewController:vc drewerHiddenDuration:0.01]; push到NextVC 后 ,用pop返回时,直接返回到根界面
我是在导航控制器的二级页面加的抽屉效果,抽屉从右边滑出
现在碰到的问题是关闭抽屉的手势和导航栏的pop手势之间有冲突。
就是侧滑时抽屉并没有被关闭,而调用到了导航栏的pop手势,抽屉的根控制器被pop掉了
以下是我的example代码:
import UIKit
import CWLateralSlide
class DrawerViewController: ViewController {
// right item
@IBOutlet weak var right: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
cw_registerShowIntractive(withEdgeGesture: true) { [weak self] (direction) in
guard let ss = self else { return }
ss.clicked(ss.right)
}
}
// right item clicked
@IBAction func clicked(_ sender: UIBarButtonItem) {
let vc = DrawerRightViewController()
let bg = UIImage.create(with: .green)
let configure = CWLateralSlideConfiguration(distance: 0, maskAlpha: 0.4, scaleY: 1.0, direction: .right, back: bg)
cw_showDrawerViewController(vc, animationType: .default, configuration: configure)
}
}
侧边栏添加TextView,设置不可点击,点击时侧边栏消失,留下灰色背景bug,需要再次点击可移除
present一个navigationcontroller后,再dismiss后,原控制器被抽屉遮盖
场景:主控制器 Main, 左滑显示控制器 A, animationType = Default, 右滑也显示控制器A, animationType = Mask , A视图有个ImageView竖直居中约束,呈现的效果是,Default动画的左侧A,不居中显示。Mask动画的右侧,则居中显示
我这边检测到我一个property button 设置的图片 发生内存泄漏
主界面是一个 self.window.rootViewController = [[NavigationController alloc] initWithRootViewController:[[ViewController alloc] init]]; ,在ViewControl 页面 隐藏了 NavigationBar ,点击仿QQ 左侧 划出 选择 push 操作 ,出来的新界面 导航条是白色 而且没有返回按钮 在返回按钮的地方 多点几次 有时能返回到 主界面 有时 回不去 ( 先侧滑一下下 再放开 再点击返回按钮的地方 就能回去) 把tabbar 设置为跟视图的时候 就没有这个问题
设导航为根视图时(self.window.rootViewController = [[NavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];),侧边栏push到下一页时动画有点闪
楼主你好!请问我用右侧划出的时候[self cw_presentViewController:vc]present到下个界面后,dismiss不能回到侧滑的那个界面而是直接回到未侧滑之前的那个界面。而我使用[self presentViewController:vc animated:YES completion:nil];这种方式present,dismiss倒是可以回到侧滑的那个界面,但是此时这个侧滑又有问题。(阴影部分出错)希望您可以回到我一下!
我这边检测到我一个property button 设置的图片 发生内存泄漏
感觉应该写成单例啊,我在leftviewcontroller里做自动布局,需要用到Configuration的distance属性。现在只能自己手动写个数值
重现方式:
1,打开热点,手机顶部会提示个人热点有多少人连接.
2,打开侧滑,
3,连续按两下Home键.
4,出现bug: 侧滑自动消失,返回到主界面,这时主界面有黑色蒙版.
覆盖在上面从左侧滑出时感觉手指滑动的距离和LeftViewController滑动的距离不一样,还有就是用手指滑动灰色区域关闭时LeftViewController会跳动一下,希望能解决一下!
选择遮盖在上面从左侧划出,然后 Push下一个页面。
虽然侧边栏有个关闭动画,但下一个页面就突然出现了,没有过渡动画,很突兀,望能优化
我把 _percent > 0.5 调成0.2才有更好的体验
#pragma mark - UIGestureRecognizerDelegate
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([[self viewController:otherGestureRecognizer.view] isKindOfClass:[UITableViewController class]]) {
return YES;
}
return NO;
}
比如我现在用的是Texture, 控制器类叫ASViewController,这样手势代码就失效了。
老项目首页上使用UIPercentDrivenInteractiveTransition添加了自定义的手势push动画,然后在首页viewdidload上添加
// 注册手势驱动
__weak typeof(self)weakSelf = self;
[self cw_registerShowIntractiveWithEdgeGesture:NO transitionDirectionAutoBlock:^(CWDrawerTransitionDirection direction) {
if (direction == CWDrawerTransitionFromLeft) {
SVLeftViewController *vc = [SVLeftViewController create];
[weakSelf cw_showDrawerViewController:vc animationType:CWDrawerAnimationTypeMask configuration:nil];
}
}];
这样子我原先在首页的Push手势就失效了,请问知道这是什么问题吗
我push告我This no UINavigationController... 但是我alloc一个UINavigationController再用cw_pushViewController push的话还是push不了,怎么解决?
项目根控制器是一个导航栏,当点击侧滑菜单中的事件进行Push时,进而二级控制器,导航栏的标题,按钮会全部消失,楼主有这种问题出现过吗
向右滑动出现界面后, 再向左滑动, 只滑动一小段距离, 跳动非常厉害
兄弟, bug有点明显啊
如果我在当前的控制器中添加了左侧的控制器leftVC, 但是没有注册手势, 只是在navigationbar的左侧有个点击事件, 点击时出现leftVC 控制器, [self cw_showDefaultDrawerViewController:leftVC];就像这样, 但是, 当我没有在当前显示leftVC 时, 我从屏幕左侧滑动, 接着, 在当前控制器中, 点击一个cell 时, 出现bug (打开图层的时候可以看到已经present出下一个控制器) , 除非再从屏幕侧滑一下.
目前好像不适用此场景”结合UIScrollView使用,滑动到最左侧滑出左侧抽屉,滑动到最右侧滑出右侧抽屉“,也不知道是不是没用对方法😔
在巨人的肩膀上😜,简单修改了下,ps:新人一枚,若改出问题,请原谅😜
1、在WynterW大神基础上修改了UIScrollView方法
`/**
2、参照原有注册手势驱动方法之外添加下面的方法
`/**
注册手势驱动方法,侧滑呼出的方向自动确定,一般在viewDidLoad调用,调用之后会添加一个支持侧滑的手势到本控制器
@param openEdgeGesture 是否开启边缘手势,边缘手势的开始范围为距离边缘50以内
@param transitionDirectionAutoBlock 手势过程中执行的操作。传整个点击present的事件即可(看demo的使用)
*/
(void)cw_registerShowIntractiveWithEdgeGesture:(BOOL)openEdgeGesture transitionDirectionAutoBlock:(void(^)(CWDrawerTransitionDirection direction))transitionDirectionAutoBlock {
CWLateralSlideAnimator *animator = [CWLateralSlideAnimator lateralSlideAnimatorWithConfiguration:nil];
self.transitioningDelegate = animator;
objc_setAssociatedObject(self, &CWLateralSlideAnimatorKey, animator, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
CWInteractiveTransition *interactiveShow = [CWInteractiveTransition interactiveWithTransitiontype:CWDrawerTransitiontypeShow];
[interactiveShow addPanGestureForViewController:self];
[interactiveShow setValue:@(YES) forKey:@"isAutoDirection"];
[interactiveShow setValue:@(openEdgeGesture) forKey:@"openEdgeGesture"];
[interactiveShow setValue:transitionDirectionAutoBlock forKey:@"transitionDirectionAutoBlock"];
[interactiveShow setValue:@(CWDrawerTransitionDirectionLeft) forKey:@"direction"];
[animator setValue:interactiveShow forKey:@"interactiveShow"];
}`
3、修改CWInteractiveTransition.m文件
新增属性
@property (nonatomic, copy) void(^transitionDirectionAutoBlock)(CWDrawerTransitionDirection direction); /* 默认NO */ @property (nonatomic, assign) BOOL isAutoDirection;
修改方法
`- (void)showBeganTranslationX:(CGFloat)x gesture:(UIPanGestureRecognizer *)pan {
//NSLog(@"---->%f", x);
if (self.isAutoDirection == YES) {
if (x >= 0) {
_direction = CWDrawerTransitionDirectionLeft;
} else {
_direction = CWDrawerTransitionDirectionRight;
}
}
if ((x < 0 && _direction == CWDrawerTransitionDirectionLeft) || (x > 0 && _direction == CWDrawerTransitionDirectionRight)) return;
CGFloat locX = [pan locationInView:_weakVC.view].x;
// NSLog(@"locX: %f",locX);
if (_openEdgeGesture && ((locX > 50 && _direction == CWDrawerTransitionDirectionLeft) || (locX < CGRectGetWidth(_weakVC.view.frame) - 50 && _direction == CWDrawerTransitionDirectionRight))) {
return;
}
self.interacting = YES;
if (_transitionBlock) {
_transitionBlock();
}
if (self.isAutoDirection == YES) {
if (_transitionDirectionAutoBlock) {
_transitionDirectionAutoBlock(_direction);
}
}
}`
4、调用
`- (void)viewDidLoad {
[super viewDidLoad];
self.tabBarController.view.backgroundColor = [UIColor whiteColor];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
[self setupNavBarItem];
[self setupScrollView];
// 注册手势驱动
__weak typeof(self)weakSelf = self;
[self cw_registerShowIntractiveWithEdgeGesture:NO transitionDirectionAutoBlock:^(CWDrawerTransitionDirection direction) {
//NSLog(@"direction = %ld", direction);
if (direction == CWDrawerTransitionDirectionLeft) {
[weakSelf leftClick];
} else if (direction == CWDrawerTransitionDirectionRight) {
[weakSelf rightClick];
}
}];
// [self cw_registerShowIntractiveWithEdgeGesture:NO direction:CWDrawerTransitionDirectionLeft transitionBlock:^{
// [weakSelf leftClick];
// }];
// [self cw_registerShowIntractiveWithEdgeGesture:NO direction:CWDrawerTransitionDirectionRight transitionBlock:^{
// [weakSelf rightClick];
// }];
}`
老哥,我centerVC 里面有个scrollView, 导致
[self cw_registerShowIntractiveWithEdgeGesture:YES transitionDirectionAutoBlock:^(CWDrawerTransitionDirection direction) {
//NSLog(@"direction = %ld", direction);
if (direction == CWDrawerTransitionDirectionLeft) { // 左侧滑出
[weakSelf leftItemAction];
}
}];
接收不到响应怎么办
遮盖在上面从左侧划出,左侧菜单只划出了屏幕的一半多一点,和预期的效果有点差别,按照你的方法在viewDidAppear里面 CGRect rect = self.view.frame; rect.size.width = CGRectGetWidth(self.view.frame) * 0.75; self.view.frame = rect;
CWInteractiveTransition.m 类中的
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer方法的返回值写反了吧。
当主页面有UITableView时,滑动UITableView会跟滑动手势冲突,导致滑动UITableView的时候,侧边的菜单栏时隐时现。
第一个右滑出来的左侧边页,在主界面区域往左划(也就是划回去)但还未完全划回去的时候,再往右划,这个时候侧边页两侧出现了白色区域,反复操作白色区域越来越大
第二个左划出来右侧边页,跟第一步基本差不多的步骤,会出现整个界面四周有白色区域,反复操作区域越来越大
接上一个问题,主动开头以为是我的tableview有问题,但是用你的demo也是出现一样的问题
`- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// NextViewController *vc = [NextViewController new];
//
// if (indexPath.row == 0 && _drawerType != DrawerDefaultRight && _drawerType != DrawerTypeMaskRight) {
// [self presentViewController:vc animated:YES completion:nil];
//// [self presentViewController:[TestViewController new] animated:YES completion:nil];
//
// }else {
// [self cw_pushViewController:vc];
// }
NSLog(@"🤪");
[self dismissViewControllerAnimated:YES completion:nil];
}`
就改成这样,重复试几次,会出现点击不响应的现象
框架侧滑出手势和UIScrollView横向滑动手势冲突,在设置ScrollView.userInteractionEnabled = NO
时,侧滑手势可用。具体案例:类似QQ音乐在UIScrollView最左侧时,再滑动时唤出左侧菜单。
大大你好,我用的这个框架遇到这样一个问题
window的rootview为A页面(登录页面)
登录成功后pre到B页面,代码如下
MainViewController * next = [[MainViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:next];
[self presentViewController:nav animated:YES completion:nil];
在B页面上点击显示左侧页面,点击左侧页面的按钮进入下一页报错
Warning: Attempt to present <NextViewController: 0x7ff3a6e17760> on <UINavigationController: 0x7ff3a8035600> whose view is not in the window hierarchy!
这样怎么解决呢
在点击事件里调用- (void)cw_showDefaultDrawerViewController:(UIViewController *)viewController,发现不走改函数。这是什么原因造成的
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.