84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
项目中用到了MMDrawerController这个侧滑框架,今天在做一个摇一摇的功能.项目框架图请看:
蓝色框的代码是实现摇一摇功能,在没有使用MMDrawerController的情况下亲测是成功的。但在使用MMDrawerController后,检测不到摇一摇,实现不了,各位看官有遇到过吗?在线等
业精于勤,荒于嬉;行成于思,毁于随。
已解决此问题。不是这个三方框架的问题,贴上完整的解决代码:在Appdelegate实现
// 支持摇晃[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
在需要摇一摇的控制器里实现如下代码:
(BOOL)canBecomeFirstResponder { return YES;}
(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self becomeFirstResponder];}
(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self resignFirstResponder];}
(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"%s", __func__);}
已解决此问题。不是这个三方框架的问题,贴上完整的解决代码:
在Appdelegate实现
// 支持摇晃
[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
在需要摇一摇的控制器里实现如下代码:
(BOOL)canBecomeFirstResponder {
return YES;
}
(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self resignFirstResponder];
}
(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog(@"%s", __func__);
}