风景模式下的FbGraph API
我正在使用FbGraph API进行Facebook集成。 一切工作正常,但问题是,FbGraph API不会在横向视图中旋转。风景模式下的FbGraph API
我也使用shouldAutorotateToInterfaceOrientation
是,我试图在didRotateFromInterfaceOrientation
放置一个断点。
它永远不会被调用。 我真的陷入了这一点。 请帮助
我下面用其做工精细,
1)中的观点,从您使用FBGraph
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
方法后通知
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;
}
这将有助于细讲到应用程序的结构,但一些步骤,以帮助有:
-
将所有ViewControllers您使用的是需要听与方法旋转定义(注意,这将为所有方向旋转,所以看如何支持纵向或横向的文档):
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; }
评论中提到这个其他SO问题(http://stackoverflow.com/questions/ 2868132/shouldautorotatetointerfaceorientation-犯规工作)
Review iOS Documentation on this和their trouble-shooting on this issue
我在所有的视图控制器中使用shouldAutorotate,但没有运气。现在发生的事情是,我有一个模态视图,当我们点击fb共享时,它调用类A,然后类FbGraph API。并且在API中没有xib。它只是显示一个显示的UIView。 –
这不是不旋转的UIView,它是侦听该事件并告诉视图可以旋转的UIViewController。当你在以前的视图控制器中时,你可以旋转你的应用程序吗?你想旋转那个UIView?子视图尊重他们的VC的设置。如果您在NavController或TabBarController中,请确保将它设置在那里。 –
我解决了这个问题我自己。 改为使用FBGraph API提供的UIView我只是创建了自己的UIViewController并在该视图控制器中实现了该API。 下一刻问题解决了......
现在用下面的方法,其工作的罚款。
在视图中使用以下代码,您将在其中使用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)];
}
您是否将Facebook API与iOS开发混淆?您可以为iOS下载的FB Graph API库是一个用于与Facebook的Graph API交互的SDK。您的设备和侦听设备状态(即在您的ViewController内)更改的应用程序将侦听这些事件。 –
我在我的iOS应用程序中使用FbGraph API,它工作得很好,问题只与方向有关。 :( –