尝试在<uinavigationcontroller>上显示<slcomposeviewcontroller>,其视图不在窗口层次结构中</uinavigationcontroller> </slcomposeviewcontroller>

时间:2014-07-07 09:50:03

标签: ios

我正在尝试在UITableView的单元格选择上实现Facebook共享。但是,我收到以下错误

尝试在窗口层次结构中显示其视图!

我的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];

if (indexPath.section == 1)
    {

    if(indexPath.row==0)
    {
        SLComposeViewController * fbSheetOBJ = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [fbSheetOBJ setInitialText:@"Hanuman Chalisa App"];
        [self presentViewController:fbSheetOBJ animated:YES completion:Nil];

    }
}
}

有任何想法吗?

谢谢,

2 个答案:

答案 0 :(得分:0)

尝试使用self.navigationController

进行演示

答案 1 :(得分:0)

首先解除左侧滑动菜单并加载主视图控制器

,我解决了这个问题
if(indexPath.row==0)
    {
        //share with facebook

        SLComposeViewController * fbSheetOBJ = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        [fbSheetOBJ setInitialText:@"Hanuman Chalisa App"];

        [self.sidePanelController.rightPanel dismissModalViewControllerAnimated:YES];
     [self.sidePanelController.centerPanel presentViewController:fbSheetOBJ animated:YES completion:Nil];

    }