I am running into a bit of a problem when I attempt to use (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event in order to capture a shake event. The problem is that the function isn't even running, even when I override canBecomeFirstResponder and set it to return YES. I have seen some other people's posts with this problem, but I have not found an answer.
Thanks for any help!
First Example .h (class inherited from UIView - Is "called" from the app delegate class) {
@class TestApplicationView;
@interface TestApplicationView : UIView {
IBOutlet UIView *view;
}
}
First Example .m {
- (id)initWithCoder:(NSCoder *)coder
{
[self setUpView];
return self;
}
- (id)initWithFrame:(CGRect)frame
{
[self setUpView];
return self;
}
- (void)setUpView
{
[self becomeFirstResponder];
NSLog(@"First Responder - %d", [self isFirstResponder]);
}
}
Second Example .h (class inherited from UIApplicationDelegate and UIScrollViewDelegate) {
#import <UIKit/UIKit.h>
@class TestApplicationViewController;
@interface TestApplicationAppDelegate : NSObject <UIApplicationDelegate, UIScrollViewDelegate> {
IBOutlet UIWindow *window;
IBOutlet UIScrollView *scrollView;
}
}
Second Example .m {
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[self becomeFirstResponder];
}
}
-- The second example returns the following warning: 'TestApplicationAppDelegate' may not respond to '-becomeFirstResponder'