iPad open a modalViewController at application launch - ipad

here is my problem: I have an iPad application based on a SplitViewController. When I launch the application, since it always starts in portrait mode, only the Detail pane is shown. All right. I want now open a modalViewController at the application launch for login purpose, but I am not able to find out the right way. I grasp on the web the following code:
SampleModalViewController *sampleView = [[[SampleModalViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:sampleView animated:YES];
and it runs nicely, but where do I have to place it in order to have the modal controller displayed at startup? I tried to override viewDidLoad in the DetailViewController, but it does not work.
Thanks for your help!
Roberto

They suggested me an answer:
http://forums.macrumors.com/showthread.php?t=1097839

Related

Warning: Attempt to dismiss from view controller <ViewController> while a presentation or dismiss is in progress

I´m new to Xcode but I keep on making some small apps to learn. I have run into a problem that only sometimes occurs with the message "Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!" and the app then crash.
I have searched around and found some possible answers but no luck for me yet.
My code for back is:
- (IBAction)Back {
UIViewController *back = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:back animated:NO completion:NULL];
I understand that the problem is that I try to go from one viewcontroller to another before the presentation of the viewcontroller is done.
The strangest thing is that this sometimes isn´t any problem and the app works flawlessly.
Ok, I think you have trouble with the concept of navigation in iOS. First take a look at iOS Human Interface Guidelines: Navigation, and then read: Navigate with UINavigationController in iOS7 (don't worry about ios 7 or 8, they're both similar)
Overall, I really recommend watching Stanford's Developing iOS 7 apps for iPhone or following the newest one: Developing iOS 8 Apps with Swift to learn!

how to use push storyboards without hiding navigation bar?

I am building an iOS app using storyboards. I integrated Facebook in my app.
I'm facing a problem after successful login via Facebook and user close the app and come
again,i want it should be on a particular screen.
I implemented push storyboard code but when user come on that screen navigation bar hides
which is my problem.
Could someone help me how I can handle this.
here is my code:
if (FBSession.activeSession.isOpen)
{
PlayNext *newView = [self.storyboard instantiateViewControllerWithIdentifier:#"Play"];
[self.navigationController pushViewController:newView animated:YES];
}

How to call a view controller from AppDelegate in iOS

I am creating an iOS app in which I have the following requeriment: the app should show the login screen when it starts the first time and also that screen must also be shown when the app comes from the background to the foreground, in case it has been sent to background during run time.
I have handled to show the screen in both cases. However, when I do it and the app comes from the background, and I click the texfield to type my password, the app gets frozen, and it fails in a thread that I don't know what it means.
I call the screen to be shown when the app comes from background like this, in the applicationWillEnterForeground, in AppDelegate:
self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RoomRootViewController* room = [[RoomRootViewController alloc] init];
[[self window] setRootViewController:room];
[self.window makeKeyAndVisible];
Is this the correct way to do so?
Thanks a lot in advance ! I am completely lost with this as I am very new in iOS, so any help will be very appreciated.
Attached in an image you can see where the app fails.
The code you are currently using is completely deleting the root view controller of your app window, in other words, you are deleting all the views and view controllers in your app. If you are not using ARC, this is just one huge memory leak. If you are, it's still not a very good idea.
In your applicationWillEnterForeground: method, try using this code instead:
RoomRootViewController* room = [[RoomRootViewController alloc] init];
[self.window.rootViewController presentViewController:room
animated:NO
completion:nil];
This will display the RoomRootViewController over the top of all your app's current views, instead of deleting them. You can then dismiss it like this:
[self.window.rootViewController dismissViewControllerAnimated:YES
completion:nil];
and easily return to the rest of your app.
It will be very messy if you are using this line of code
self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
It means every time you are creating new instance of UIWindow which will contain UIViewController and all other component each time. Which means when you go to background and comes to foreground the old window instance has been flushed off and it will contain new components that's why when you click on the UITextField it has been deallocated, The reason you are getting error. Don't create new instance of window and use the code as #PartiallyFinite does.
Hope this helps.

iAD - adBannerView rotation

In my iPad app that supports all the device orientation, I add an adBannerView to the main view.
So far so good. It works and the ad rotates as expected.
If I click on a particular ad this is visualized full-screen, and when I close it I get back to my app.
The problem is that if you rotate the device while you are visualizing the full-screen ad, this rotates correctly, but when you close it and come back to the app the view is not rotated.
How to solve this? Please help or I will destroy my iPad! ;-)
Basically, you want the
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
method to be called again...
To do that, when the user closes the iAd, simply execute:
UIViewController *correctOrientation = [[UIViewController alloc]init];
[self presentModalViewController:correctOrientation animated:NO];
[self dismissModalViewControllerAnimated:NO];

calling a second view in iPad app

I am trying to adapt an existing application to an iPad app. The application has a main view that calls View2 that is in "View2.xib". Everything has been working well, until I entered the following:
if(!view2Controller)
{
view2Controller = [[View2Controller alloc] initWithWindowNibName:#"View2"];
}
[view2Controller showWindow:self];
This works in my original Cocoa program, but in the iPad application it is currently returning a warning: "Thread1: Program received signal "SIGBRT" While working with it, I've also received a message Method -initWithWindowNibName not found.
Similarly, I have the same problem with the method showWindow.
I wonder how it is that this problem shows up when I try to convert it to an iPad app.
I've run out of ideas to check and would appreciate some assistance.
You will need to change it to the following
if(!view2Controller)
{
view2Controller = [[UIViewController alloc] initWithNibName:#"View2" bundle:nil]
}
//If you are in a view controller use
[self presentModalViewController:view2Controller animated:YES];

Resources