横向模式下的FbGraph API

时间:2011-12-06 05:24:21

标签: iphone facebook-graph-api ios4

我正在使用FbGraph API进行facebook集成。 一切都运行正常,但问题是FbGraph API不会在横向视图中旋转。

我还将shouldAutorotateToInterfaceOrientation用于YES,我试图在didRotateFromInterfaceOrientation中添加断点。

永远不会被召唤。 我真的很喜欢这个。 请帮忙

4 个答案:

答案 0 :(得分:1)

我在下面使用它的工作正常,

1)在您使用- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

FBGraph视图方法中发布通知

2)

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
{

     [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"CHANGE_ORIENTATION" object:orientation]];

}

3)在FBGraph

-(void)authenticateUserWithCallbackObject:(id)anObject andSelector:(SEL)selector andExtendedPermissions:(NSString *)extended_permissions {

    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc addObserver:self selector:@selector(shouldAutorotateToInterfaceOrientation:)
               name:@"CHANGE_ORIENTATION"
             object:nil];
   -----------
 -------
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(NSNotification *)notofication

{

    if([notofication.object isEqualToString:@"LEFT"])
    {
        CGAffineTransform newTransform;
        newTransform = CGAffineTransformMakeRotation(M_PI * 270 / 180.0f);
        webView.transform = newTransform;
        [webView setFrame:CGRectMake(12, 0, 320, 480)];
        NSLog(@"LEFT");
    }
    else if([notofication.object isEqualToString:@"RIGHT"])
    {
        CGAffineTransform newTransform;
        newTransform = CGAffineTransformMakeRotation(M_PI * 90 / 180.0f);
        webView.transform = newTransform;
            [webView setFrame:CGRectMake(0, 0, 305, 480)];
        NSLog(@"RIGHT");
    }
    else if([notofication.object isEqualToString:@"PORTRAIT"])
    {
        CGAffineTransform newTransform;
        newTransform = CGAffineTransformMakeRotation(M_PI * 360 / 180.0f);
        webView.transform = newTransform;
            [webView setFrame:CGRectMake(0, 12, 320, 480)];
        NSLog(@"PORTRAIT");
    }
    else if([notofication.object isEqualToString:@"DOWN"])
    {
        CGAffineTransform newTransform;
        newTransform = CGAffineTransformMakeRotation(M_PI * 180 / 180.0f);
        webView.transform = newTransform;
            [webView setFrame:CGRectMake(0, 0, 320, 465)];
        NSLog(@"DOWN");
    }
    return YES;
}

答案 1 :(得分:1)

使用以下方法,并且工作正常。

在视图中使用以下代码,您将在其中使用fbgraph。

@ i-bhavik 感谢核心理念。

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {

    NSLog(@"left");

    [self leftOrienation];

    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
    [self rightOrientation];
    NSLog(@"right");
    }
    else
    {

    }

    //  Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||      interfaceOrientation == UIInterfaceOrientationLandscapeRight);

    }

这里我已将FbGraph初始化为fbGraph。

   -(void)leftOrienation
   {
   CGAffineTransform newTransform;
   newTransform = CGAffineTransformMakeRotation(M_PI * 270 / 180.0f);
   fbGraph.webView.transform = newTransform;
   [fbGraph.webView setFrame:CGRectMake(0, 0, 768, 1024)];

   }

   -(void)rightOrientation
   {
   CGAffineTransform newTransform;
   newTransform = CGAffineTransformMakeRotation(M_PI * 90 / 180.0f);
   fbGraph.webView.transform = newTransform;
   [fbGraph.webView setFrame:CGRectMake(0, 0, 768, 1024)];

    }

答案 2 :(得分:0)

详细介绍您的应用程序结构会很有帮助,但有一些帮助的步骤是:

  1. 设置你正在使用的所有ViewControllers需要使用定义的方法来监听旋转(注意这将针对所有方向旋转,所以请查看有关如何支持Portrait或Landscape的文档):

    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    { 
         return YES;
    }
    
  2. 回顾提及此问题的其他SO问题(http://stackoverflow.com/questions/2868132/shouldautorotatetointerfaceorientation-doesnt-work)

  3. Review iOS Documentation on thistheir trouble-shooting on this issue

答案 3 :(得分:0)

我自己解决了这个问题。 而是使用FBGraph API提供的UIView,我只创建了自己的UIViewController,并在该视图控制器中实现了该API。 下一刻问题就解决了......