UIPopoverController? Cannot dismissed when tapping outside the popover controller - iphone

I have a problem that began after I changed my project to a universal application and switched to the updated version of Xcode.
At the moment, my application has a navigation bar with a controller that has a button. The button will pop up a UIPopoverController when the user clicks it. Everything was fine here. Now I try to interact with the list inside UIPopoverController and there is no reaction at all in the list. In addition, when I try to dismiss the popover controller by tapping outside the popover controller, the popup does dismiss at all as well as I can even interact the controls behind the popover controller.
It worked fine before I updated Xcode to the latest IOS. Inside the code I have changed was having the xib file to have the window view and inside the app delegate file I initialized that xib file.
This is shown the code below.
TViewController* controller = [[TController alloc] initWithNibName:#"MainViewController_IPad" bundle:NULL];
[controller.navigationController setNavigationBarHidden:TRUE animated:TRUE];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[self.window setRootViewController:controller];
[self.window makeKeyAndVisible];
//((TopicShowViewController*)self.window.rootViewController).navigationController.navigationBarHidden = true;
self.navigationController = ((TopicShowViewController*)self.window.rootViewController).navigationController;
self.navigationController.navigationBarHidden = true;
[controller release];
The code above, I have to create the window object but the TViewController itself has a window object already. If i run this without either window object in the xib file or explicit initialized the window object from code above, the TViewController won't display as expected.
I have no idea what is going wrong here... Sorry the description may be too long to understand but please help.

A universal application is an app designed to run on both an iPhone and an iPad. However, the UIPopoverController is not supported on the iPhone. If you try open a popover on an iPhone your app will throw an exception.

Related

How should I replace the rootViewController of my main window?

I'm building an app that does a ton of setup when the app loads. As such, I have a loading view that displays some information to the user while the setup takes place...
MyLoadingViewController *loadingViewController = [[MyLoadingViewController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = loadingViewController;
[self.window makeKeyAndVisible];
.
.
//Setup code happens here
.
.
MyHomeViewController *homeViewController = [[MyHomeViewController alloc] init];
self.window.rootViewController = homeViewController;
When the setup code completes, I want to transition into my home screen. Is setting the rootVewController to the new home view controller the proper way to do that kind of a transition?
Thanks so much for your wisdom!
Yes, that's an ok way to do it -- you won't have any animation, but it should work fine. loadingViewController will be deallocated after you switch the root view controllers -- if that's not what you want, then you should create a property to point to it.
I sometimes cheat a little by having the ViewController that does all the loading display an image that is the exact same as the default.png on screen while it loads, then animate it out once complete.
For example in my LoginViewController I firstly display the default image in viewDidLoad, contact the server for auto login and then fade out the image once the app logins. The user never notices as he just sees the default image fade out once the app is ready.

App wont start using testflight on iOS6

I have an application that I want to test it on iOS device. The application uses NIB files and no story board.
Target framework is set to - 5.1
Device - Universal.
I have created the IPA file and uploaded to TestFlightApp.
I have downloaded and installed the application on my iPad. Weird thing is when I tap on the icon a black screen shows and nothing else happens.
I have done the following settings.
Main Interface - SSDMainViewController
Main Storyboard - Not set as I don't have any storyboard in the applicaion.
It is not the problem of IOS versions as other apps are working fine.
EDIT : When I double click the iPad button I saw that the application
is not crashing. It is running in the background.
EDIT 2 : More information on the question.
Well I have taken a view based application and it has all NIBs no storyboard. It was initially an iPhone application targeting the IOS 5.1 but then I have changed the value from the project drop down to UNIVERSAL. But that I think is no problem because when I installed it in my iPad it showed me nothing. Also it showed black screen with the iPhone frame and then nothing. The application is still live in the thread.
What bothers me is that I have done this in the AppDelegate :
I have set the
self.mainViewController = [[SSDMainViewController alloc] initwithnibname:#"SSDMainViewController" bundle:nil];
And then I have set the navigation controller and then pushed the view to it.
I FOUND SOME MORE INFORMATION
In the console it says.
The application is expected to have its root view set at the end of application start.
MY APP DELEGATE
ftipValue=0.25;
cardtype = #"American Express";
[cardtype retain];
[self CallFunctionForLogout];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Create an instance of YourViewController
//SSDMainViewController *yourViewController = [[SSDMainViewController alloc] init];
self.mainViewController = [[[SSDMainViewController alloc] initWithNibName:#"SSDMainViewController" bundle:nil] autorelease];
// Create an instance of a UINavigationController
// its stack contains only yourViewController
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:self.mainViewController];
navController.navigationBarHidden = YES;
// Place navigation controller's view in the window hierarchy
[[self window] setRootViewController:navController];
[self.window makeKeyAndVisible];
return YES;
Please use two xib file, universal app we want two xib (nib)
one for iPhone - ViewController_iPhone
second for for iPad - ViewController_iPad
Add following code to your AppDelegate.m file.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPhone" bundle:nil] autorelease];
}
else {
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I have done this and it's work fine for me.
That error means that you're not setting up your application correctly.
You say you've set SSDMainController as the main interface file - is this both for iPhone and iPad? There are two sets of entries in that section of the summary tab for universal apps.
I would expect a different xib file to be specified for the iPad, since a different sized view and different layout would be in use.
You have either not set the iPad xib, so the app can't set up a window with root view controller, or you haven't set up a valid iPad xib, so it isn't loading at all, with the same results.
If you just want the app to run in the mini-iPhone window with the 2x button, leave it as an iPhone only app.
If you are getting "The application is expected to have its root view set at the end of application start." there are a number of possibilities. Clearly, that is the problem, since you have a black screen with nothing in it...
Check out this SO question: Application windows are expected to have a root view controller at the end of application launch warning Rob Mayoff has a good description of what should be happening when your application initializes.
Also, linked to in the above post, is this post wherein there are an additional 35 answers with various scenarios of what could be happening.
Beyond browsing through those links, you will need to post up additional code and/or descriptions of how your nibs are wired up for anyone to help you--as evidenced by the myriad ways it is possible to cripple the initialization sequence.

UIImagePicker can't perform full-screen transition on iOS 3.1.3

I am modifying my iphone app to make it backward compatible with iOS 3.1.3. I allow the user to load images from the photo library. I present the image picker with the following code:
UIImagePickerController* content = [[UIImagePickerController alloc] init];
content.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
content.delegate = self;
[self presentModalViewController:content animated:YES];
[content release];
This works correctly on ios 4.0+. However, on ios 3.1.3, the image picker never appears, and I get the following warning:
Can't perform full-screen transition. The fromViewController's view must be
within a view that occupies the full screen.
The fromViewController in this case is the visible view controller within a navigation controller. The navigation controller is set up in the appDelegate didFinishLaunchingWithOptions using the following code segment:
MyViewController* root = [[MyViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:root];
aNavigationController.delegate = self;
[window addSubview:aNavigationController.view];
Prior to attempting to load the image picker, another view controller is presented in the navigation controller. Therefore, at the time the image picker is loaded, two view controllers are in the navigation stack.
Based on another post, I have tried using the root view controller and the navigation controller as the fromViewController (the controller presenting the image picker). The behavior is the same.
I'm wondering if the problem has anything to do with the fact that the navigation controller's modalPresentationStyle cannot be set in iOS 3.1.3. For iOS 3.2+, I set the presentation style to UIModalPresentationFullScreen. I believe this is the default for previous iOS's. However, I'm suspicious simply because the warning I'm getting concerns full-screen views.
Can anyone provide any other suggestions? I have not been able to find any Apple documentation that addresses changes to UIImagePicker or UINavigationController from ios 3.x to 4.0.
Thanks in advance!
What I usually do when the view controller is inside a navigation controller is:
imagePicker = [[UIImagePickerController alloc]init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
[self.navigationController presentModalViewController:imagePicker animated:YES];
Hope it works for you!

Problem with getting a modalViewController to appear

I've been fighting with this for hours. I've searched around everywhere and just can't seem to find the solution to my problem. I'm pretty sure I'm just lacking some key concepts here.
My AppDelegate (didFinishLaunching) basically sets up my window and invokes RootViewController:
// create our window
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setBackgroundColor:[UIColor blackColor]];
// create our rootviewcontroller
RootViewController *controller = [[RootViewController alloc] init];
// add our rootviewcontroller's view to our window
[window addSubview:controller.view];
// controller is now owned by window's view
[controller release];
// show us to the world
[window makeKeyAndVisible];
When I add controller.view as window's subview, my understanding is that RootVC's loadView will automatically get called.
In RootVC loadView, I create a tabBarController, each tab having a navigationController and it's own viewController. All that is working fine.
In RootVC viewDidLoad, I'm checking to see if this is the first time a user is running this app, and if so, I want to throw up a modal welcome screen. This is the part I'm having trouble with.
I'd like to keep as much code out of the RootVC's viewDidLoad method, and ideally would be able to accomplish what I want with this:
WelcomeViewController *welcome = [[WelcomeViewController alloc] init];
[self presentModalViewController:welcome animated:true];
[welcome release];
Obviously this isn't working. WelcomeVC's loadView hasn't been run yet because I haven't explicitly set it's view property. I've played around with a bunch of different solutions (welcome.view - [[UIView....], using WelcomeVC's init method to set self.view) but I just can't seem to get that modal to pop up.
How should I accomplish what I'm looking for? What are the best practices, and what's the best solution to keep my code tight and tidy?
I'm stuck, so hopefully your solution will allow me to continue developing my app!
Although the problem is not so simple, the solution is. You have to wait until the main view appears. So check the condition and present your modal view in viewDidAppear method, not in viewDidLoad method.

UINavigationController navigation stack problems in landscape mode

I have an iPhone application that I am currently converting to a universal binary to work with the iPad. I have successfully implemented everything I need in terms of layout so that full landscape functionality is now supported in my app (previously I primarily used portrait mode to display content).
But, I have one strange problem, and it ONLY occurs in landscape mode: when I push a view controller onto the stack, it takes two taps on the back button to return to the previous view controller! The first tap shows a blank view, but with the same name on the left-side back navigation button, the second tap takes the controller back to previous view like it should.
I don't have an iPad to test, so I am relying on the simulator. The problem does not show up on the iPhone and doesn't show up if you rotate back to portrait mode.
My app consists of a tabbarcontroller with navigation controllers loaded for its vc's:
//application delegate
- (void)applicationDidFinishLaunching:(UIApplication *)application
//....
WebHelpViewController *vc8 = [[WebHelpViewController alloc] init];
UINavigationController *nv8 = [[UINavigationController alloc] initWithRootViewController:vc8];
[self.tabBarController setViewControllers:[NSArray arrayWithObjects:nv1,nv2,nv3,nv4,nv5,nv6,nv7,nv8,nil]];
To implement landscape capability, the UITabBarController is overridden to autorotate when required:
//CustomTabBarController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return [[(UINavigationController *)self.selectedViewController topViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
... works fine. I navigate into new views using this method
SomeViewController *vc = [[SomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
Is this only a simulation error? How do I fix this problem?
It sounds like another ViewController is responding to:
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
Check this first.