FBlogin dialog box orientation problem - iphone

I'm facing a very silly problem and its really hard to resolve for me.
The fblogindialog box that i'm using in my application, appearing in portrait mode always.. But my whole application is in landscape mode.. the main thing is that the keyboard appears landscape and the web view in wich the login appears has the orientation which just suits the landscape mode (means the username and pwd txt boxes are that much wide so that if we rotate the device it would just fit into the landscape mode).
I tried every thing i looked for the status bar orientaition as well. its really frustrating. i'm using a button named post and on the click of this button i written the following code:
AppDelegate_iPhone *appDelegate =(AppDelegate_iPhone *)[[UIApplication sharedApplication]delegate];
if (appDelegate._session == nil)
{
appDelegate._session = [FBSession sessionForApplication:_APP_KEY secret:_SECRET_KEY delegate:self];
}
if(self.loginDialog == NULL || ![appDelegate._session resume])
{
self.loginDialog = [[[FBLoginDialog alloc] init] autorelease];
loginDialog.delegate = self;
[self.loginDialog show];
//self.loginDialog.frame = CGRectMake(0, 0, 480, 320);
[self.view addSubview:loginDialog];
}
here is the screen shot link-- http://i.stack.imgur.com/X4UHi.png
Please help me guys..
Thks very much .

finally i used new facebook sdk to solve this problem. and used the graph apis . A sample which explain all of this is --
https://github.com/reallylongaddress/iPhone-Facebook-Graph-API
and very helpful indeed.
Thanks

Related

ViewController doesn't show until I quit and relaunch app

I have just made my app universal by combining separate iPhone and iPad projects. Everything seems to be working but there is one major bug.
When the iPad app launches it just displays a black screen (presumably the window) and status bar. When I press the home button I suddenly see the SplitViewController as it disappears. When I open the app up again the SplitViewController is displayed.
I can't figure out why the controller only displays after I close and reopen the app. Any ideas?
(I don't have any idea what is causing this so if you need code samples from specific places let me know).
Thanks.
Edit:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Appirater appLaunched:YES];
// Registers this class as the delegate of the audio session.
[[AVAudioSession sharedInstance] setDelegate: self];
// Allow the app sound to continue to play when the screen is locked.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
justOpened = YES;
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
{deleted}
} else {
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
CGRect rect = CGRectMake(-2, self.window.frame.size.height-29, self.window.frame.size.width+2, 29);
imgBar = [[UIImageView alloc] initWithFrame:rect];
imgBar.contentMode = UIViewContentModeScaleToFill;
imgBar.image = [UIImage imageNamed:#"wood_btm.png"];
imgBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;
self.splitViewController.showsMasterInPortrait = YES;
self.splitViewController.title = #"Exams";
self.splitViewController.splitPosition=280;
}
return YES;
}
Update:
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear. This is obviously not the ideal solution though so if anyone can think of a cause let me know.
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
return YES;
should be at the end of -applicationDidFinishLaunching:WithOptions: method.
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear.

iPhone GameCenter won't showAchievments

So my problem is that after integrating gamecenter nicely into my iphone app, it won't show the achievements list!
The integration was a success I think because when I use the submitAchievement method, I do unlock achievements on the list. But I must look at the list from the GameCenter App on the iPhone, not within my own app as it doesn't work.
ikuragames first help me get the code right (thx you !!) but it still doesn't work ! :(
-(void)showAchievments
{
//NSLog(#"showAchievments");
GKAchievementViewController *achievements = [GKAchievementViewController alloc] init];
if (achievements != nil)
{
achievements.achievementDelegate = self;
[(EAGLView *)self.view achievmentsWillAppear];
[self presentModalViewController:achievements animated:YES];
}
}
- (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
//NSLog(#"achievementViewControllerDidFinish");
[glView achievmentsWillDisappear];
[self dismissModalViewControllerAnimated:YES];
}
On debug mode, I can clearly see that each line or code are "processed" and not error whatsoever is displayed. BUT, nothing appears on my screen :(
Can you please help me ? (here is some doc.)
I found the answer.
Turned out that the view controller I was sending showAchievments to was not the view controller I wanted.
I was doing something like:
[[myViewController sharedInstance] showAchievments];
But the sharedInstance method returned a brand-new, vanilla-initialised myViewController, and not the one I was already using.
Now it works perfectly, I hope this will help someone in the future.

UIImagePickerController Camera Source Problem

Ok here is the code that I wrote to display the UIImagePickerController in the camera source. I just declared the myPhotopicker in the header for the property and retain it. Synthesized it in the main code file. Then calling the picker I wrote the code below:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
if (myPhotopicker==nil) {
myPhotopicker = [[UIImagePickerController alloc] init];
myPhotopicker.delegate = self;
}// create once!
myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:myPhotopicker animated:NO];
}
Upon calling it, there are a few things that is weird happening to the app.
Sometimes, when there are many apps running in the background (iPhone4), the app would fail to load the camera and crash the app. Though it will load CameraRoll/PhotoAlbums without problem.
If the camera view is able to load (when there are less apps running in the background), tapping the Cancel button on the camera view results in the app rebooting itself (where the Default.png image is shown quickly, and back to the main page - like when we started the app).
I have been trying to figure out this problem, but not sure what to do... pls help.. Thanks.
here is the complete code of image pickercontrol try too find solu. here.
http://www.icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/
Regards,
Shyam Parmar
Rather than your 'create once' logic try creating and releasing each time.
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
myPhotopicker = [[UIImagePickerController alloc] init];
myPhotopicker.delegate = self;
myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:myPhotopicker animated:NO];
[myPhotopicker release];
}
You should also implement the delegate to remove the modal view controller from view when it is dismissed (if you haven't already).
You should also check that the current class conforms to the UINavigationConrollerDelegate protocol.

game center not working on ipod/iphone

Hi all
Working on a universal build for an iphone/ipod/ipad app. I was trying to get game center working within this app. I now have the game center working on the ipad but for some reason it still wont work on the ipod/iphone and i have no idea why.
highScoreVC=[[UIViewController alloc] init];
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:highScoreVC.view];
[highScoreVC presentModalViewController:leaderboardController animated: YES];
}
this is my code for displaying the leaderboard and it does work everytime for ipad but as i said not for other devices. the code is still being called the same as for ipad so i have no clue why it is not displaying. any ideas why this would be? cheers
As far as I'm concerned, [GKLeaderboardViewController init] will return nil if the device is not authenticated with Game Center by that point. Are you sure you are correctly authenticated on the devices causing problems?
I suspect there may be some issues with how your UIKit items for Game Center are being displayed if they are working fine on the iPad but not iPhone/iPod. I experienced similar sounding issues when converting an app to universal.
If you create a new standalone iPhone/iPod project just for testing does game center display fine?
ok i got it working in the end.
cocos2d 0.99.5 has indeed made some changes that to how this works. the following code displays the leaderboard correctly
-(UIViewController*) getRootViewController{
return (UIViewController*)([(BubbleDreamsAppDelegate*) [[UIApplication sharedApplication] delegate] viewController]);
}
and then
highScoreVC = [self getRootViewController];
GKLeaderboardViewController *leaderboardController = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[highScoreVC presentModalViewController:leaderboardController animated: YES];
}
hope this helps anyone that gets stuck with same problem

UIImagepickerController [takepicture] modal view disappears no delegate callback

Update:
This has been answered. It was my own stupidity, possibly not worth reading any more of this question. lol.
Question:
Right so i have this UIViewController(master) subclass, it has a UIImagepickerController(camera), it also has a UIView(overlayView). Master setups the camera to be configured as a camera only with a custom cameraOverlay, hiding the custom controls e.t.c.
All appears to work fine apart from when i try to programatically take a picture. What happens is the overlayView calls the master and this triggers the take picture, then i hear the shutter sound and the iris closes, the camera appears to dismiss itself (i am defiantly not doing this in my code) and then my viewDidAppear gets called in my master again.
Anybody have any idea whats going on ?
-(void)viewDidLoad
{
NSLog(#"loading the view");
//if the camera is on the device
if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
//make one
camera = [[UIImagePickerController alloc] init];
//setup some settings that we need
camera.sourceType = UIImagePickerControllerSourceTypeCamera;
camera.showsCameraControls = NO;
camera.navigationBarHidden = NO;
camera.toolbarHidden = YES;
camera.cameraViewTransform = CGAffineTransformScale(camera.cameraViewTransform, 1.03, 1.03);
//show it
overlayView = [[OverlayView alloc] initWithFrame:CGRectMake(0,0,320,480) withDelegate:self andController:self];
camera.cameraOverlayView = overlayView;
camerashowing=NO;
}
else
{
alert = [[UIAlertView alloc] initWithTitle:#"No Camera Detected" message:#"The camera is broken or your device has no camera. Please close the application" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
}
-(void)viewDidAppear:(BOOL)animated
{
if (!cameraShowing)
{
NSLog(#"going to show camera");
[self presentModalViewController:camera animated:NO];
camerashowing = YES;
}
}
-(void)releaseShutter
{
[overlayView toolbarShowWarning];
NSLog(#"going to show camera: %#", self);
[camera takePicture];
}
After some help advice from people in the answers i can say that the camera is not being released.
I have also managed to stop the exec_bad_access by stopping it from calling [presentmodal....] for a second time by checking a bool value in the viewDidAppear Method.
I still have the issue where the modal view disapears, any help, again lol ??
I think you're missing a camera.delegate = self;
For any EXC_BAD_ACCESS errors, you are usually trying to send a message to a released object. The BEST way to track these down is use NSZombieEnabled.
This works by never actually releasing an object, but by wrapping it up as a "zombie" and setting a flag inside it that says it normally would have been released. This way, if you try to access it again, it still know what it was before you made the error, and with this little bit of information, you can usually backtrack to see what the issue was.
It especially helps in background threads when the Debugger sometimes craps out on any useful information.
VERY IMPORTANT TO NOTE however, is that you need to 100% make sure this is only in your debug code and not your distribution code. Because nothing is ever released, your app will leak and leak and leak. To remind me to do this, I put this log in my appdelegate:
if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled"))
NSLog(#"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
If you need help finding the exact line, Do a Build-and-Debug (CMD-Y) instead of a Build-and-Run (CMD-R). When the app crashes, the debugger will show you exactly which line and in combination with NSZombieEnabled, you should be able to find out exactly why.
Check the value of the camera member variable before you try and display it:
NSLog(#"going to show camera: %#", camera);
I suspect it might be being released somewhere, but as coneybeare NSZombieEnabled will let you track it down.