Hi all I have an app where I allow the user to post something on their pinwall of facebook. I used the DemoApp directly from Facebook to set it up.
I have implemented a shake detection that does something when the user shakes the device. However, since those two functions are in the same viewcontroller, both of them dont work anymore.
- When Facebook pops the login window, the keyboard doesn't appear anymore.
- Shakes are not detected anymore.
I suppose it has something to do with the first responders. I have tried a lot of things but I was not able to solve it. Here is the neccessary part of my code.
Post something on facebook pinwall:
- (IBAction)publishStream{
FactsAppDelegate *appDelegate = (FactsAppDelegate *)[[UIApplication sharedApplication] delegate];
NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init]autorelease];
[dictionary setObject:@"Du postest diesen Fact:" forKey:@"user_message_prompt"];
[dictionary setObject:[[appDelegate.facts objectAtIndex:currentFactId] fact] forKey:@"message"];
[_facebook dialog:@"feed" andParams:dictionary andDelegate:self];
}
Shake detection:
#pragma mark Motion catching
// shake motion began
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (motion != UIEventSubtypeMotionShake) return;
// load next fact
[self next];
// vibrate
[self vibrate];
}
Method needed for shake detection:
#pragma mark Shake events are only detectable by the first responder
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self resignFirstResponder];
}
Can anyone tell me what I have to change to get both (facebook, shake) working? Thanks a lot, doonot