我遇到了问题,无法知道原因或解决方案 我有AddDelegate和另一个ViewController,在这个ViewController中我添加了FBFriendPickerViewController,而ViewController将被添加到AppDelegate ..
我将ViewController添加到AppDelegate,如下所示:(此ViewController是SocialSharing类)
if( socialSharing == nil )
socialSharing = [[SocialSharing alloc] init];
[_window.rootViewController.view addSubview:socialSharing.view];
在ViewController(SocialSharing)中添加FBFriendPickerViewController,如下所示:
-(void)shareOnFaceBook:(NSNotification *) notification
{
if( shareOnUserOrFriendWallBtnIndex == 0 )
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *facebookSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSURL *candidateURL = [NSURL URLWithString:contentDataToShare];
if (candidateURL && candidateURL.scheme && candidateURL.host) {
[facebookSheet setInitialText:@"See this link .."];
[facebookSheet addURL:candidateURL];
}
else // Event ***
{
[facebookSheet setInitialText:[NSString stringWithFormat:@"%@%@%@",[[appDelegate.extrasOverlayView.markerData.btnsArr objectAtIndex:0] objectForKey:@"markerName"],@" .. \n", contentDataToShare]];
[facebookSheet addURL:[NSURL URLWithString:lastVideoLink]];
}
//Brings up the little share card with the test we have pre defind.
[appDelegate.window.rootViewController presentViewController:facebookSheet animated:YES completion:nil];
} else {
//This alreat tells the user that they can't use built in socal interegration and why they can't.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure you have at least one Facebook account setup and your device is using iOS." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
else if( shareOnUserOrFriendWallBtnIndex == 1 )// post on friend's wall
{
if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]] )
{
NSLog(@"Facebook is inastalled on this device.");
if( friendPickerController == nil )
{
friendPickerController = [[FBFriendPickerViewController alloc] init];
friendPickerController.delegate = self;
if( !( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) )
friendPickerController.title = @"Select Friends";
}
[friendPickerController loadData];
// Present view controller modally
[self presentViewController:friendPickerController animated:YES completion:nil];
}
else{
NSLog(@"This device has no Facebook app.");
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't invite friends, Facebook app isn't installed, please install it and retry again." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
}
并从SocialSharing中解除friendPickerController,如:
- (void)facebookViewControllerCancelWasPressed:(id)sender
{
NSLog(@"Friend selection cancelled.");
[self dismissViewControllerAnimated:YES completion:nil];
}
我用过:
[friendPickerController dismissModalViewControllerAnimated:YES];
OR //[self.view.window.rootViewController dismissViewControllerAnimated:YES completion:Nil];
OR //[self dismissModalViewControllerAnimated:YES];
它只适用于第一次,一旦,friendPickerController出现并在关闭时关闭,但是当再次调用打开时,我有这个错误:
"线程1:信号SIGBRT"
对于以下行:
[self presentViewController:friendPickerController animated:YES completion:nil];
注意:当我在AppDelegate上直接添加friendPickerController(在AppDelegate的类中)而没有另一个类(这里是SocialSharing ViewController)时,它的效果很好..
我正在开发IOS 7和Facebook SDK 3.13 .. 那么,问题是什么,我该如何解决?
谢谢
答案 0 :(得分:0)
我做了什么来解决我的问题,我在NORMAL CLASS中创建了friendPickerController,而不是ViewController,并在AppDelegate上添加它
[appDelegate.window.rootViewController presentViewController:friendPickerController animated:YES completion:nil];
并解雇:
[appDelegate.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
并将此类称为:
if( socialSharing == nil )
{
socialSharing = [[SocialSharingClass alloc] init];
[socialSharing initSocialSharing];
}
尽管如此,我还不知道这个问题,但这解决了它。可以帮助任何人。