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.
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
Thanks to XJones I was finally able to fix my problem.
@XJones, I was reducing my app to the default functions and found out why I was not able to catch motions and why I had problems with the facebook keyboard.
My MainWindow.xib file was totally wrong and delegate was not set either. I deleted the xib file, mapped delegate and window and that's it, I can now catch motions and even facebook posting works like a charm :)
Thanks a lot for taking care and offering your help!!