FbGraph API in landscape mode


I am using FbGraph API for facebook integration. Everything is working fine, but the problem is that the FbGraph API does not rotate in landscape view.

I also used the shouldAutorotateToInterfaceOrientation to YES, and i tried to put a breakpoint in didRotateFromInterfaceOrientation.

It is never being called. I am really stuck into this. pls help


I use below and its work fine,

1) post notification in - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation method of view from which you use FBGraph


- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation { [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"CHANGE_ORIENTATION" object:orientation]]; }

3) In the 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; }


Am using the following method, and its working fine.

Use the following code in the view, in which you are going to use fbgraph.

<strong>@i-bhavik</strong> thanks for the core idea dude.

- (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); }

<strong>here i have initialized FbGraph as fbGraph.</strong>

-(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)]; }


It would help to go into detail into your application structure, but some steps to help are:


Set all ViewControllers you're using that need to listen to the rotation with the method defined (note this will rotate for ALL orientations, so look at the documentation on how to support Portrait or Landscape):

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } </li> <li>

Review other SO issues that mention this (http://stackoverflow.com/questions/2868132/shouldautorotatetointerfaceorientation-doesnt-work)

</li> <li>

<a href="http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html#//apple_ref/doc/uid/TP40007457-CH101-SW22" rel="nofollow">Review iOS Documentation on this</a> and <a href="http://developer.apple.com/library/ios/#qa/qa1688/_index.html" rel="nofollow">their trouble-shooting on this issue</a>

</li> </ol>


I solved this problem myself. instead using the UIView provided by FBGraph API I just made my own UIViewController and implemented that API in that view controller. and the next moment the problem was solved...


  • how can I sort properly with preg_match?
  • How to post images in facebook in iphone app?
  • Implement delegates for Core Data's fetched results controller or not
  • Swift: How to get row number of a button in each table row?
  • Does performSelector perform right away or is it scheduled to be performed?
  • Deleting a row in tableview without deleting Core Data Entity
  • Assigning the contents of a file to an variable
  • performSelector in NSOperation subclass
  • JavaScript get page coordinates of closest clicked character
  • select only 1st level of nested elements
  • How do I interpolate a line number from __LINE__ into the name of a test in Perl?
  • How to cache data in ios
  • Get highlight text in current window and send it in a popup
  • How to make the tableview response pan gesture in ZUUIRevealController
  • How to replace TouchesBegan with UIGestureRecognizer
  • how to remove a div with same ids but display='block' and display='none' in JAVa
  • Jquery popup on mouse over of calendar control
  • iOS: Detect app start via notification press
  • how to adjust image in a panel in Java swing?
  • How to access EntityManager inside Entity class in EJB3
  • how to do an event when i swipe from fragment to the other
  • JFileChooser in front of fullscreen Swing application
  • HTML download movie download link
  • How to draw moving and Running sine wave chart using JFree chart in java?
  • Possible to stop flickering java tooltip in heavyweight mode?
  • sending/ receiving email in Java
  • Eraser for UIBezierPath
  • jquery mobile loadPage not working
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Suggestions to manage Login/Logout transitions
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • How to stop GridView from loading again when I press back button?
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • Observable and ngFor in Angular 2
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?