Question

I used Facebook SDK on my app. After i pressed "Add feed to your wall", the alert pops up with "YES" or "NO". If i choose "YES" the FBStreamDialoy just flash away.

First , click the button " Add feed to your wall" to call changeFeed: function:

-(IBAction) changeFeed
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sporting Summer Festival Monte-Carlo" message:@"Are you attending this concert?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes",nil];
    [alert show];
    alert.tag = 1;
    self.alertView =alert;
    [alert release];

}

Then, press "YES" button. Call this function:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        NSLog(@"NO");
    }
    else
    {
        NSLog(@"YES");
        [self showAddFeed];
    }

}

And this is the showAddFeed function , which is defined in front of clickButtonAtIndex.

-(void)showAddFeed
{
FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease];
    dialog.delegate= self;
    dialog.userMessagePrompt = @"*****";
        [dialog show];
}

Just cant work well. I don't know why? Thank you for your help.

------------Answer is--------------------------

[self performSelector:@selector(fbButtonClick) withObject:nil afterDelay:0.10];
Was it helpful?

Solution

Call it after a delay of 0.1 sec [self performSelector:@selector(fbButtonClick) withObject:nil afterDelay:0.10];

OTHER TIPS

The problem is that you listen to:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

Which should be:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

Because at the clickedButtonAtIndex function the view isn't closed and this can cause problems.

Edit: To make it work in iOS 4 add your facebook login call to a method and call the following function in the didDismissWithButtonIndex:

[self performSelectorOnMainThread:@selector(facebookOpenAction) withObject:nil waitUntilDone:NO];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top