Convert iPhone app to universal app: Grouped UITableView - iphone

I am using xib-s for my UITableViewCells on iPhone. Now I need to convert my app to universal app. Do I have to create new xib-s (looking exactly the same way) for the iPad version? My current problem is that I am using grouped UITableViews. As the left and right margins on both devices differ, some of the controls on iPad are partly "out of the cells".
In case I need new xib-s (looking exactly the same way), do I need separate properties for the controls in the ViewController? For example, for a label named myLabel, do I need a second property myLabelIpad or is there a better way to handle that?
Cheers

My suggestion is to create new xib. But if there are small changes , then you can maintain one xib. However it depends on how different your iPhone / iPad versions are. For example, if the iPad version is just a bigger version of the iPhone one with a few extra buttons, etc, it's easier to use one UIView and just set the frames of the subviews appropriately.

First understand what you are up to. How do you want your iPad app to look like? How does it navigate. Ceratinly you want to leverage from the lager screen of the ipad. When ever you do that and the auto-resizing mechanism is not sufficient (which it rarely is) then go for a separated xib file.
Second - for each XIB which hosts the same number and types of UIView and UIConrol subclasses, you should be able to use the same view controller for two separate XIBs. Just link all conrols within both XIB to the related IBOutlet properties and IBAction methods alike.
However, when you take leveraging from iPad capabilites seriously then you are like to end up with a different set of view controllers. That is when you can combine the controls of several iPad views wihin one single iPad view and similar cases.
Nevertheless, think of using popups. The content of a popup could nicely correlate to what is a full screen on the iPhone. In that case you can use the same view controller again within that popup container.
Does this sort of answer your question? If not, then please be more specific.

Actually you can retain the same Table cell xib files. You just have to get the Auto resizing masks of the cell and its subviews right.

Related

Fitting controls on iPhone screen app when converting from iPad app

This might be a question specific to my app.I have an iPad app functional. I am converting it to iPhone app. So on one of my iPad screens i have 40-50 controls (labels, textfields,buttons,etc). Now can i achieve something like that on my iPhone also. Screen for iPhone is small and i can barely put 20 controls on one screen. Can i have a long vertical scroll view to put all my controls on one screen. I mean user can scroll down and down and have the same exact controls on this iPhone screen as on iPad screen but with different orientation. Or should i separate that one screen into multiple UIViewControllers? Please let me know if you need more information. Thanks.
Simple answer: You can do anything you want.
More elaborate: You could do a scroll view like you mention, but I'm sure this would be sub-optimal. You have a few options to deal with the difference in devices. The one you choose usually depends on the view or the amount of content it contains. You can 1) Simply resize it for the other device (this only works in rare situations where you have a simple view or one without much content). 2. You create a separate view controller for each and launch the appropriate one for the device (per apple docs). You could just slap your view in a scroll view, but depending on the specifics, a tab view, navigation controller, or some other option may provide a better user experience. In the end it's up to you...

Code design question using UIViewControllers (drawing PDFs page by page) - best practice?

I have written a little PDF viewer which is supposed to show PDFs page by page to reduce memory usage.
It consists of a PdfViewController which shows a specific page of the PDF (using UIScrollView, CATiledLayer).
Now the (maybe stupid) question is: if I want to show the next page (using a swipe gesture ot whatever), how would I do that? Should my controller handle it and update its views (which is a horror becaue CATiledLayer seems to crash as soon as you look at it :-)), or should there be an "outer" controller which generates a new PdfViewController for every page flip (the more flexible aproach)?
What is the best practice in these situations? Looking at UINavigationController, you're supposed to push a new UIViewController for every level. But there, all controllers being pushed may be different. In my case, all pages are using the same controller.
You likely shouldn't use the UINavigationController for that. In general, the UINavController should be used for drill-down operations, where you have a limited set of items to be pushed.
In your case, I think the best option is to use a large UIScrollView which will take care of the pagination and then just create a new UIView with the CATiledlayer inside.
I created for my app Quicklytics a PagedViewController class that does most of that for you. You basically create a PageDataSource that creates the UIViews for each page, and handle it over to the control. You may not use this exactly as is on your code, but it'll give you a good idea on where to go:
https://github.com/escoz/monotouch-controls/blob/master/UICatalog/PagedViewController.cs
Hope this helps you.
Here are two useful resources
Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints? collects a whole lot of information on displaying pdfs.
https://github.com/vfr/Reader a basic pdf reader for ios that does what you are trying to do.
In terms of whether to use nested UIViewControllers I would recommend against it, however if you do you should be aware that they will not handle rotation very well (I don't think they receive orientation change events) as well as viewDidAppear and other view lifecycle events, also make sure only to display modal view controllers from the root view controller otherwise they won't show properly (I had issues with them appearing in the wrong orientation in landscape, or in the wrong position).
In the app I built I used one UIViewController to manage the display of the pdf and I subclassed NSObject for any other "sub" controllers to make it more manageable. For example I had vertical scrolling as well as horizontal scrolling of pdf pages. My first attempt used nested UIViewControllers however I had issues with orientation till I rebuilt using controllers subclassed from NSObject for managing vertical slides.

one UIViewController and multiple UIViews each

I want to have one iPad screen with multiple independent sections that can be dragged by the users finger.
Each section will have different objects like UIButton, UILabel, UIImage, etc. When the section is dragged, all of the associated objects in that section will moved with it as a group.
Therefore I was thinking each section could be a UIView or a UIViewController.
The whole thing should be under one UIViewController type (navigation etc).
I been trying different things but nothing works fully, only pieces of it works. I tried using different UIViews, and loading nibs into that, but then the buttons don't respond to touches.
Anybody got any ideas?
As per Apple's Review Policy:
https://developer.apple.com/appstore/resources/approval/guidelines.html
Apps that create alternate
desktop/home screen environments or
simulate multi-app widget experiences
will be rejected.
I would recommend rethinking your design (not trying to be rude !!)

How to make a universal app

I have a iPhone app I want to convert to an universal app so it can run on iPad. I have tried to find information about how to do it, but I don't find anything that answers my question. I have upgraded the iphone target in xcode to ipad. Then I get a new MainWindow-iPad.xib.
But I have many viewcontrollers and I have made those with code, not xib's. Do I need to have a if-clause in the loadView method that loads different viewcontroller depending on if the user has a iPhone or iPad?
It kind of depends on how you've implemented your loadView methods and how you want your iPad version to differ from your iPhone app.
If you just want your app to use the full screen, you can mostly just check the size of the screen and size your views appropriately and use the autoresizing mask to deal with things when you change orientations.
There are a few gotcha's with this approach, though. For example, modal views can work differently (not taking up the whole screen) and, obviously, the keyboard is a different size.
If you want to use completely different views for your iPad app then, yes, you'll quite possibly have if statements that tell it to use completely different view controllers.
Yes you have to create all xib's for iPad and then you have to write if-clause for Ipad xib to be loaded.

Making large toolbars like the iPod app

I am trying to create a toolbar programatically (rather than via IB) very similar to the toolbar featured in the iPhone app:
Currently I've been experimenting with the UIToolbar class, but I'm not sure how (and if?) you can make the toolbar buttons centrally aligned and large like that in the iPod app.
Additionally, regardless of size, the gradient/reflection artwork never correctly respects the size and is stuck as if the object is the default smaller size.
If this cannot be done with a standard UIToolbar, I guess I need to create my own view. In this case, can the reflection/gradient be created programmatically or will it require some clever alpha tranparency Photoshopped artwork?
The best thing you can do is:
create MyToolbar.h and MyToolbar.m : MyToolbar can be inherited from UIToobar
create an empty xib named MyToolbar.xib
In Interface Builder, add a new UIToolBar with "IB->Tools->Library"
With "IB->Tools->Inspector", change the class identity to "MyToolbar"
Now, you can customize your toolbar with IB or with xCode as you want.