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

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

Related

Only seeing white splash screen

I try to load a loginView in my app delegate but it only shows the original white splash which sais something like "Welcome to universal app".
I am quite puzzled.
I have created a loginView.xib. Files Owner's class is LoginViewController.h. The view is linked to Files Owner.
I load the view like this in applicationDidFinishLaunchingWithOptions
LoginViewController *loginVw = [[LoginViewController alloc] init];
[self.window addSubview:loginVw.view];
[self.window makeKeyAndVisible];
Any idea what I am missing?
The designated initialiser for a UIViewController backed by a XIB is - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle.
Your code should look more like
LoginViewController *loginVw = [[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil];
Documentation and sample code is your friend in this case.
replace
LoginViewController *loginVw = [[LoginViewController alloc] init];
with
LoginViewController *loginVw = [[LoginViewController alloc] initWithNibName:nil bundle:nil];
so the LoginViewController actually uses your .xib

iphone - Tabbar application with NavigationController, without MainWindow.xib

Hihi all,
I am pretty new in iPhone dev. I have follow some tutorial and created a tabbar application. Below is the code in the appdelegate implementation:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController1 = [[ViewController1 alloc] initWithNibName:#"ViewController1" bundle:nil];
UIViewController *viewController2 = [[ViewController2 alloc] initWithNibName:#"ViewController2" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
Then set the title and the image for the tab in each of the controller implementation.
My problem is that, example, in my viewController1, I need to navigate to viewController3, when I use presentModalViewController method to push the viewController3 in, the tabbar at the bottom will be disappeared.
While I tried to use the app delegate to refer to my tabBarController, and use tabBarController.navigationController pushViewController method, my viewController3 is not being pushed, and seems nothing happens.
I have tried to follow a few tutorial, but it's all required to drag in the navigationcontroller into the MainWindow.xib, which, in the xcode 4, MainWindow.xib doesn't exist anymore. How can i create the navigationcontroller from code so that the app can navigate between different view without hiding the tabbar?
Any comment is very much appreciated! Thanks in advance!
:)
If you want to use a navigation controller, you need to create a navigation controller. Since you're not using a XIB, you'll have to create it manually.
Since you want the tab bar to remain visible when you present viewController3, you need to make the navigation controller a child of the tab bar controller.
UIViewController *viewController1 = [[ViewController1 alloc] initWithNibName:#"ViewController1" bundle:nil];
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
UIViewController *viewController2 = [[ViewController2 alloc] initWithNibName:#"ViewController2" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:
navController1,
viewController2,
nil];
Then when you want to present viewController3, do this:
// in some method of viewController1
[self.navigationController pushViewController:viewController3 animated:YES];
I am not very Sure but have you tried this??? Actually i am going to use XCode 4 soon, i am still using 3.2.8 version:-
WebViewController *viewController = [[WebViewController alloc]initWithNibName:#"WebViewController" bundle:nil];
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewController animated:YES];
[viewController release];
See in this also the Tab bar will be removed when you navigate to your 3rd screen, you have to provide the navigation bar to come back.
Hope it helps.. :)

iphone app not working ipad simulator

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.

Universal App issue

Everybody..
I have create one universal application..
My app worked fine to only two view..
In iphone app worked fine to MainView -> First View -> SecondView -> ThirdView..
But in iPad only works to MainView -> First View .. After it can not call to SeconfView..
I have call also this view but not called..
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
languageObj = [[LanguageSelection alloc] initWithNibName:#"Language_iPhone" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:languageObj animated:NO];
}
else if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
languageObj = [[LanguageSelection alloc] initWithNibName:#"LanguageView_iPad" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:languageObj animated:NO];
}
Nib name also perfect.. View outlet also set in nib file.. But LanguageView not called in iPad only..
Please let me know, is there any wrong thing which i had done..
Thanks..
Now this solved..
I need to add only one line in didFinishLaunchingWithOptions method..
UINavigationController *navCont = [[UINavigationController alloc] initWithRootViewController:menuView];
Thanks for who do their effort to solve my question.. Thanks..

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?