iphone app not working ipad simulator - iphone

My iphone app runs on iphone simulator and devices but not on ipad simulator. It doesnt showing any errors but the application is not launching just blank black screen only displays.
While running in ipad simulator 5 it showing following error "applications are expected to have a root view controller at the end of application launch"
My application didFinishLaunchingWithOptions code is as below :
rootViewController = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];
[self.rootViewController.view setFrame:CGRectMake(0, 20, 320, 460)];
[self.window addSubview:self.rootViewController.view];
[self.window makeKeyAndVisible];
return YES;
And my main.m code is as below :
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
What is the wrong with this???

Go on the App Target info and set "Target device Family":"iPhone" then it works fine both on iphone and ipad simulator and device both.

What if you change this:
rootViewController = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];
to this:
self.rootViewController = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];

Check....Navigation Controller delegate must have been connected (delegate > AppDelegate) in IB.

Related

Downloaded 6.1sdk yesterday now [self.tabBarController presentViewController:... does not work

I upgraded to x code 4.6 SDK 6.1 and now
[self.tabBarController presentViewController:loginViewController animated:YES completion:nil];
is Threading out.
This code worked with 6.0 on 6.0 and below simulators but now 6.0 and 6.1 crash while 5.1 and below simulators still run fine.
Basically in my app delecate i call a tab bar then run a login screen ontop of that till its dismissed.
EDIT: I am not using AutoLayout anywhere.
Got it I was under the impression that adding ~iPad/~iPhone to my xib name would work for a universial app in choosing which xib to use automatically. Well on the 5.1 simulators it does however on 6 and above it does not.
so here is the correct code.
LoginViewController *loginViewController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[FirstViewController alloc] initWithNibName:#"FirstViewController_iPhone" bundle:nil];
viewController2 = [[SecondViewController alloc] initWithNibName:#"SecondViewController_iPhone" bundle:nil];
loginViewController = [[LoginViewController alloc] initWithNibName:#"LoginViewController~iPhone" bundle:nil];
} else {
viewController1 = [[FirstViewController alloc] initWithNibName:#"FirstViewController_iPad" bundle:nil];
viewController2 = [[SecondViewController alloc] initWithNibName:#"SecondViewController_iPad" bundle:nil];
loginViewController = [[LoginViewController alloc] initWithNibName:#"LoginViewController~iPad" bundle:nil];
}

Splash screen with activity indicator works fine in iOS6 but not in iOS5

I would like to show a splash screen view with activity indicator to load some information from a server before entering inside my app. Below is how I do it:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
FeedViewController *feedViewController = [[FeedViewController alloc] initWithNibName:#"FeedViewController" bundle:nil];
MenuViewController *menuViewController=[[MenuViewController alloc] initWithNibName:#"MenuViewController" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:feedViewController];
IIViewDeckController* deckController = [[IIViewDeckController alloc] initWithCenterViewController:self.navController leftViewController:menuViewController rightViewController:nil];
deckController.panningMode=IIViewDeckNoPanning;
deckController.panningView=menuViewController.view;
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
// show splash screen until data is loaded
SplashScreenViewController *controller = [[SplashScreenViewController alloc] initWithNibName:#"SplashScreenViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[feedViewController presentModalViewController:controller animated:NO];
return YES;
}
In FeedViewController.m, I did something like this:
- (void)viewDidLoad
{
// load data from a server
[self performSelector:#selector(dismissSplashScreen) withObject:nil afterDelay:0.0];
}
This code works very well with iOS6, but when I tested it with iOS5 the splash screen with activity indicator spinning just does not disappear. I suspect I might implement a splash screen in a wrong way. (But I don't understand why this works in iOS6?)
I solved this problem myself by using a bool variable to check whether the splash screen should be shown. The code for showing the splash screen is moved to viewDidLoad of FeedViewController instead.
This approach seems to work well for both iOS5 and iOS6.

iPad crashes when running iPhone app in compatibility mode

I just had one of my apps reviewed, and I never knew this but apparently an iPhone specific app must also be able to run on the iPad in compatibility mode... I never knew this, and it doesn't really make sense.
Anyways, my app is crashing when calling didFinishLaunchingWithOptions
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *rootViewController;
rootViewController = [[[WPViewController alloc] initWithNibName:#"WPViewController_iPhone" bundle:nil] autorelease];
self.viewController = [[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];
self.viewController.navigationBar.barStyle = UIBarStyleBlack;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
Using NSLog, I can see that it crashes when I call [self.window makeKeyAndVisible]; And also, if I remove that line of code and run it in the iPad simulator, it does not crash, but obviously shows a blank screen. The app runs fine on the iPhone simulator
Any ideas? or places to start looking?

UIActivityIndicatorView is not working (getting Facebook permissions affecting UIActivityIndicatorView)

I have a tabbarcontroller with three tabs/viewcontrollers.
When I first start my app, with my ActivityIndicator set to be visible and animated - courtesy of interface builder - it works fine.
However when I click a button an internet window opens to Facebook in order to get the user's permission.
Once the Facebook part is taken care it returns to my app but the ActivityIndicator is not longer animated - it is still visible though, just frozen.
If I switch to another tab/viewcontroller and then come back to the tab/viewcontroller with the ActivityIndicator everything works fine.
Is there a way to refresh my ViewController so that I don't have to programmatically make the ViewController switch back and forth? Or any other suggestions?
/* I searched the forums and I saw a similar question. It appeared that there was a broken connection. Therefore I'll include the code where I add the ViewController (i.e., "controller" to my tabbarcontroller). */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
controller = [[DemoAppViewController alloc] init];
controller.view.frame = CGRectMake(0, 20, 320, 460);
controller.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"movieAppBackground.jpg"]];
MyTabBarViewController *vc2 = [[MyTabBarViewController alloc] init];
SecondViewController *vc3 = [[SecondViewController alloc] init];
controller.title = #"Intro Screen";
vc2.title = #"Explore";
vc3.title = #"Send a Pic";
UITabBarController *tbc = [[UITabBarController alloc] init];
tbc.viewControllers = [NSArray arrayWithObjects:controller, vc2, vc3, nil];
self.theTBC=tbc;
[controller release];
[vc2 release];
[vc3 release];
[tbc release];
[self.window addSubview:tbc.view];
[self.window makeKeyAndVisible];
return YES;
}
whereever u have used NIB file to show with viewcontrollers u have to create them with initwithname
Example
SecondViewController *r=[[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil];
like this change whereever u have used nib file to create instance,
i meaned for all custom viewcontrollers u have created with NIB file

App crashes on iPhone 4?

This code causes my app to crash on an iPhone 4 and on the simulator but works perfectly fine on a 3GS. Any ideas why this might be?
-(IBAction)startButtonClicked{
GameViewController *screen = [[GameViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];
[screen release];
}
Have you checked out what's happening in screen's viewWillAppear and viewWillLoad methods? It looks like some issue in your init code there. Where are you opening a URL?