View doesnt navigate in real ipad device but works fine in emulator - iphone

In a button click I am navigating the view to another xib which works fine in real iphone device, ipad iphone both emulators but not in real ipad. Here is my code :
-(IBAction)cardAnimation{
ViewController_ipad *view = [[ViewController_ipad alloc]initWithNibName:#"ViewController_ipad" bundle:nil];
[self.navigationController pushViewController:view animated:YES];
}
but one thing to be noticed that I have done NSLog in my destination class's viewdidload method and surprisingly that thing is being logged though that view is not being loaded at all by the above code. What can be the problem?

I think you have a MainWindow~ipad.xib file that is referenced through your AppDelegate and you also tried to alloc the Window in your didFinishLaunchingWithOptions: method in your AppDelegate file. For which there might be some problem occurred. Whenever you are trying to push your navigation controller, it is actually pushing, but not showing the next controller may be because of the Window over that controller.
It might solve your problem:
Go to your Project settings (not through File->Project Settings) by clicking on your Project at the left panel/navigator -> select your TARGET and go to Summary Tab -> scroll down to iPad deployment Info -> there you'll find the Main Interface option -> remove the name "MainWindow_iPad" and left it empty and save it. Run the application in your iPad and it will work fine.
Best of luck. :-)
N.B: Don't forget to clean your build and remove the application from your device before you go for the new build.

The iPhone simulator is case-insensitive for file names. The devices are case- sensitive. Check to make sure that your nib name isn't actually Viewcontroller_ipad or ViewController_iPad or another variation. This behavior once got me trying to use an image file in my app - it would work in the Simulator, not on device.

Try a fresh install (deleting the app), and if you are building from xcode hold Option and go to Product - > Clean Build Folder
Also are you naming your nibs with ~iphone and ~ipad?

I faced the same problem, i had problem with my iPad (iOS 5.1.1).
When i was pressing button but that was not responding.
That is because of i added UIGestureRecognizer on self.view.
I solved this problem by adding gestureRecognizer on my button. (its just trick not an proper solution, Just implement it if you did not find any other way.)

Related

integrating iOS4 project into iOS5 project

I have a newbie question about integrating two iOS apps. I have created an app in iOS 5 (my first app so I dont have any knowledge of iOS 4 except the fact thah there were xibs files instead of storyboard and also ARC was not included).
Now I have to include one older standalone app (built for iOS 4 with xibs and non ARC) to my iOS 5 app. Lets say that in my app on Main menu view there will be a new button opening the main menu of the other app.
So I did some research and find out how to disable ARC by the fno-objc-arc flag. Fine, now I have imported all the files of the second app to mine app and all the classes have the flag set.
I can still run my app without problem.
Now I have no idea how to let my new button to open the mainViewController of the old app - this app has MainWindow.xib (contains a window and one navigation controller). This MainWindow is set to be Main Interface in the old project. There are also some init call in appMainDelegate file. Where can I call them in my app?
Could anybody tell me what needs to be done. I have an idea, that I will add only one new UIViewController to my storyboard. This will be the starting point for the old app and than everything will work as it used to. Or will I have to create more controllers (for every xib) in my storyboard? This is where I dont know what to do. Any help much appriciated. thank you
Try doing something like the following, anything like it or simmular should work:
In the method of the button (the one you call your new button) have it execute the following code:
OldAppMainViewController *controller = [[OldAppMainViewController alloc] init];
//Here you can assign vallues to any properties that you might want to
[self.navigationController pushViewController:controller animated:YES];
That old apps main view controller should have a init with nub named function so it should work. If this does not work try something along the lines of:
OldAppMainViewController *controller = [[OldAppMainViewController alloc] initWithNibName:#"OldAppMainViewController" bundle:nil];
Where the NIB name is the .xib file name without the extension.
Also make sure that all connections in interface builder is setup correctly

Root View Controller Error

I'm working along with the book Beginning iPhone 3 Development, and am running into some issues on the "Pickers" app. I'm using Xcode 4.2, and I set it up exactly like they have it set up in their source code. All the code is the same, and all the outlet connections are the same. But, when I run my version, it launches a black screen, and the debugger says "Applications are expected to have a root view controller at the end of application launch."
There version in the source code runs just fine, and mine looks identical to it, but for some reason mine just won't run. I've Googled this issue and people have a bunch of workarounds, but I feel like there is something really simple in IB that I'm not seeing.
Any help would be great, thanks.
The iPhone 3 book is probably having you add the view of your view controller as a subview of the window, correct? Well, since iOS 4, UIWindow now has a rootViewController property and setting this property to your initial view controller is now the preferred way to get your first view controller on screen.
Basically replace something like this in -application:didFinishLaunchingWithOptions: in your application delegate...
[self.window addSubview:viewController.view];
with this...
self.window.rootViewController = viewController;
Quite a bit has changed since iPhone OS 3; beware as you proceed through the book.
Do you have the RootViewControllers XIB-file? And is it connected to the RootViewController Class (in designer)

Changes in Interface Builder are not showing in SImulator or Device

I have a view that I created using default buttons and background in Interface Builder. The app runs properly. I added .png background images to the view and to the buttons. Build the app and run it and the updates do not show.
I've also tried something simple like changing the text of the button or add another button and the changes are not propagating.
I've cleaned targets, manually deleted builds in Finder, and have shutdown the computer. What else am I missing?
I had the same experience. It turned out that I'd renamed my class and my xib file, but in another class I was creating the view with:
MyNewViewController *myNewViewController = [[MyNewViewController alloc]
initWithNibName:#"MyOLDViewController" bundle:nil];
An oversight, but the surprising part to me is that when this Nib file didn't exist in my project, it managed to build successfully using a (presumably cached?) old Nib file... and the application happily ran, though showing an out of date interface.
Correcting what was passed to initWithNibName immediately corrected the issue for me.
This might sounds easy - but are you sure you linked up the view to the view controller in Interface Builder? I've done it before where I just forget to link them
I also had the same experience. For me the fix was to reset all content on the simulator.

iOS 3.1.2 [UIViewController dismissModalViewControllerAnimated:] creates infinite recursion

I have some code that works fine on my iPod Touch running some 4.0-series iOS as well as the simulator that comes with the iOS SDK 4.1. But when I call [UIViewController dismissModalViewController:] on an iPhone 2 running iOS 3.1.2 it get an infinite recursion, eventually crashing.
I have a view controller that opens a table view where the user selects a document to open. Upon selecting a document my table view controller's delegate calls the parent view controllers dismissModalViewController method. I think it is because I'm closing the view controller whose code is running that causes this.
dismissModalViewController is documented to be available in iOS 2.0 and later.
How can I close the UIViewController that's open from its own code?
I figured my problem might be heap corruption from some previous code. A way to debug that is to comment off snippets of previous code to see whether the bug would go away or come back. Almost immediately I found that I was calling dismissModalViewControllerAnimated: on the current view controller's parent controller. Why that works in iOS 4.x I have no idea. The problem I face is that I have two modal dialogs that I need to close simultaneously, which I cannot get working, but that is a different question.

Buttons make my multiview iphone app crash! (but single view is okay)

This is probably some rookie mistake, but I can't figure it out. I've established a button within my app to recall a link in safari. From my method file it looks like this:
Obj C Code:
-(IBAction)linkSafari{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://en.wikipedia.org/"]];
}
I linked it up in IB and all seems okay.
When I create this same setup as a single view app it works great, but whenever I click it in my multiview app it's an automatic crash. Acts the same way on both my simulator and physical ipod.
Is there an endless list of places I could have screwed up or is there a certain area I should look into?
I don't think the problem is in that particular function,
but on the way you create the views and viewcontrollers
For anyone interested, this was solved thanks to an extra set of eyes. On my tab bar, I'd declared the assigned nibs for every section, but missed a few class associations. That's what messed me up.