can TTURLMap from three20 map to a xib-file? - iphone

ive made an app for the iphone and wanted to make it work on an ipad too.
for the navigation i used three20. all the views are viewcontrollers with xib´s.
for later developement, i just wanted to make the xibs in the bigger format as new skin and let the background-programm the same, so that in the end each viewcontroller would have 2 xib´s as skins.
so, three20´s URLMap can link to class-files. but how can i link to a xib ?
i wanted in the appdelegate to make the URLMap depending on the device, so that the programm it self can stay as is with its URL-Calls.

ok, now i used to overwrite the initWithNibName in combination with [UIDevice currentDevice].model to let the viewcontroller check, on which device he loads

Related

How do I make my app universal? (3.5", 4", and iPad)

I'm brand new in Xcode and have been able to scoot by with some fairly simple apps thanks to my previous programming experience, the Storyboard in Xcode, and most of all THIS WEBSITE.
One thing I haven't been able to figure out is how to make my app universal? The way I have my app set up is that it looks a lot like the iPhone home screen with pages and app icons. However, when I hit the little "Change to iPhone 5" button, 1) It only changes my FirstViewController and 2)My icons are all out of alignment.
Do I make another storyboard (If so, how?)? Do I make another view controller for each screen resolution? For either of those questions do I program a test to see which device I'm using and for it to choose the correct storyboard or ViewController? My app is currently set to universal, but I still haven't even been able to find the iPad resolution option for view controllers and stuff.
Please be as simplistic as you can. I have only been doing this for an extremely short time. Thanks for all your help both here and around this site!
So In order to get the iPad version working, follow these steps:
First go to your target settings, scroll down to "Deployment Info", and change it from iPhone to Universal
Next you will need to create a new Storyboard file. On the bar at the top go File>New>File and this thing should pop up:
After you have selected iOS>User Interface>Storyboard as shown above, click next and it will ask iPhone or iPad. After selecting iPad, the new file will be ready to map your interface for iPad. However, you need to make sure the app uses it. So go back to your target settings and scroll back down to "Deployment Info" and switch to iPad:
Set the "Main Interface" option to the name of your new storyboard file.
As for preparing for iPhone 5, that part can get a bit annoying. I find that the additional space is too small for any major additions but too large to be ignored easily. How you deal with it will vary greatly depending on what you app does. From what you described, with app icons like the iPhone screen, you will probably want to have an additional row of icons, just like the iOS. To do this, you can either manage it programatically or you may want to have seperate storyboards for iPhone 4 vs iPhone 5. If you want the separate storyboards, this question will have your solution.
To initialize storyboard:
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
UIViewController *initialViewController;
if (iOSDeviceScreenSize.height == 480)
{
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35
UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:#"iPhone4" bundle:nil];
// Instantiate the initial view controller object from the storyboard
initialViewController = [iPhone35Storyboard instantiateInitialViewController];
}
if (iOSDeviceScreenSize.height == 568)
{
// iPhone 5 and iPod Touch 5th generation: 4 inch screen
// Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4
UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:#"iPhone5" bundle:nil];
initialViewController = [iPhone4Storyboard instantiateInitialViewController];
}
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
return YES;

How To Port an iPad Application to the iPhone

I have an existing iPad - Application, no I want to make an universal App.
There are many Tutorials with making iPhone Apps universall, but i dont find how to make iPad apps Universal. Is there somebody having experienxce with this?
No Storyboards are used, yust normal xib.
I've readed this tutorial, and porting iPhone apps to universal seems to be better supported by xcode:
http://www.raywenderlich.com/1111/how-to-port-an-iphone-application-to-the-ipad
I would think that the basic idea would be the same, whether you were converting an iPhone app to a universal app, or an iPad app to a universal one(?)
Set the iOS application target to "Universal".
If a view controller, say, XYZViewController has an associated xib for its UI, then - when you create a xib for the iPhone interface - append ~iphone to the name of the iPhone interface and ~ipad to the iPad one, i.e. their file names are
XYZViewController~iphone.xib and XYZViewController~ipad.xib. That way the right xib will be picked up if you pass nil or #"XYZViewController" as nib name to the designated initializer for the view controller. (It's worth noting that the same IBOutlet can be hooked up to the corresponding UI elements in both xibs simultaneously.)
In code, whenever you need to use a different display metaphor that depends on the device type (say you want to use , check for the device type through the test
if ([UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{ ... } else { ... }
Another place where you might want to use this test is in VC's shouldautorotatetointerfaceorientation: method.

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

Return to mainview from webView deployed using storyboard

I created a new project "Single View Application" and designed the mainView with Storyboard. My main view contains a UIButton that opens the camera, the camera scans barcode and automatically goes to a website. Now I created a webView programmatically so that website can open and also created a UIButton inside the webView. Now I want that UIButton to act as home botton and return to mainview. I am unable to do that, please help.
ViewController.m code: http://cl.ly/FKj8
My storyboard looks like:
You really should look into the View Controller Programming Guide -- by switching around the contents of a single view controller, you're making a lot of extra work for yourself with little benefit. By using multiple view controllers when you want to have different "screens" in your app, you can take advantage of storyboarding for easier development, and you automatically get better memory management (read: less potential for crashes), too.
However, to more directly answer your question... if you're putting the WebView into the view hierarchy with [self.view addSubview:webView], you can remove it with [webView removeFromSuperview]. (This means you'll have to keep a reference to the WebView around so you can refer to it when you want to dismiss it.)
I also noticed in the code you posted to cl.ly an unrelated method -deviceModel which uses uname() to get device information. This is a bad idea, for two reasons:
uname() isn't guaranteed to do something useful on an iOS device (even if it currently does). Use the UIDevice class instead if you need this kind of info, or...
Generally, you don't want to test for the device name to enable functionality in your app; instead, you should test for the capabilities you need. (For example, if you look for a device name starting with "iPhone 4" to test for a Retina display, you'll miss the 4th-generation iPod touch, and the iPhone-5-or-whatever-they-call-what's-next. Instead, use the UIScreen class.)

Converting an iPhone app to a Universal app?

I have an iPhone app with
FirstViewController and SecondViewController with respective views FirstView.xib and SecondView.xib.
Now I want to make this app work with both iPhone and iPad. For iPad I need to merge Firstview.xib and SecondView.xib into a single ThirdView-iPad.xib.
What would be the best approach? Do I need to write another ViewController class for iPad or can I use existing FirstViewController and SecondViewController with single xib?
My research so far says that there is no way to use multiple ViewControllers with single xib. Please let me know the best way to do this.
Thanks
if you are using Xcode4 you can use "transition to universal target" and it will do everything needed
http://xcodebook.com/2011/05/making-an-ios-target-universal/
if you dont have it then I recommend to keep controllers out of your xib. xib files will be only containing views for iphone and ipad but the controllers "can" be same. and you can control your logic from the rootviewcontroller, just an idea..it all depends on your project.
You would be best of to just create a new ViewController unless you're into masochism. Reusing in that way would most likely be to much trouble, and I'd go with aggregation or inheritance in the case you need to reuse logic in your ViewControllers.
I typically create a base ViewController, say XYZViewController and then create a XYZViewController_iPhone with all iPhone-specials and a separate XYZViewController_iPad for iPads. But if they're totally different I give them unique names and their own NIBs as well as ViewControllers.
There Are following Rules To Convert The Iphone App to Univarsal App
1) In Plist File Add NSMainNibFile~ipad .... MainWindow_ipad(ipad window).
2) Implement separate Names Xibs (Iphone & ipad)
3)in Target Targeted Device Family set to (iphone/ipad)
and set The Frames According To Ipad &iphone
For example
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
btnHme.frame=CGRectMake(971,6, 32, 32); //ipad
}
else
{
btnHme.frame=CGRectMake(438,6, 32, 32); //iphone
}
cheers