UIViewController Margins - uiviewcontroller

I have this a simple question: How do I resize a UIViewController's view from a custom UINavigationController, since it's not working to simply set it's frame.
I have tried to, in my UIViewControllercategory, override setFrame of all UIViews, which didn't go well...
In a tableViewController I know I can set the tableview's contentInset, but that doesn't really help me here.

I think you can add another view to your UIViewController 's view's subviews. Then change the frame of this internal view is easy.

Related

Table Views. View controller vs Table View controller?

I have been watching a lot of tutorials on Table Views, table view cells etc. When creating a table view why choose a UIViewController over a UITableViewController in Xcode? For instance what would be the main benefits of creating a UIViewController and then adding a tableView object, over just creating a UITableViewController? I have already created a large numbers of scenes within storyboard and I hope I haven't limited myself in doing so. I hope my question is clear as I am new to coding!
UIViewController gives you more control over tableview rather than UITableViewController. You should use UITableViewController only when you are just concerned with tableview in a controller. But if you want to add more subviews/controls in a controller other than tableview, then you have to use UIViewController.
EXAMPLE:
If you just want to display grocery items list with some header and footer, then tableviewcontroller should be priority. But if you want to display mail items in tableview, you would need some additional buttons for altering items in mail(tableview). For later case, you will use viewcontroller. Hope my point is clear.
I think the benefits of having a View Controller is just more versatility and you will have a easier time to add other views other than the UItableview. Whereas UITableViewController i just inheriting a UIViewController, but with the delegates already set up for you. Basically it is assuming you will have a UITableView for sure. In the end it shouldn't really limit you, just cause you used UITableViewController, since everything you want to do in UIViewController, you can do in UIViewController.

Flash Builder 4.6, Mobile, Dynamic load image into custom ItemRender

Where is good place to load image in custom itemrender for list. I try to do it in createChildren where i create my holder for image, but data is not set yet.. I think in data function is not ok, because is calinig every time when user scroll.
You need to set the data/url to the image in commitProperties.
You didn't tell us what the image is and how it relates to your itemRenderer. Here are a few options:
If your image will not change based on the data then create your image class in createChildren(). Set the property on it in the createChildren() method; if it is static. If it is something that may change you may consider setting it in commitProperties().
If your image will change based on the data; then you should change it either in the set data method or in a dataChange event handler. I prefer the latter, but that is just preference. An itemRenderer is re-used as the list is scrolled. So the data that your renderer represents changes with it; and so should your visual display.
If lots of the elements of your dataProvider may use the same image; you can write conditional logic to determine whether or not the image should be loaded again. This would prevent the image from reloading again unnecessarily.

Relocating controls in UIViewController

I have a problem trying to relocate a UILabel when loading a View. I can move the label if I run this code
lTarget.frame = CGRectOffset(lTarget.frame, 0.0f, -75.0f);
from for example a button action, it works properly. But where should I put this code if I want it to be called on the view load?, I tried viewDidLoad and viewWillAppear but this doesn't work.
I need to relocate this label because I want a different layout for the 3.5 inch screen.
Any idea?
If you are using a xib or storyboard with Autolayout enabled, it will cause your view size and position to be recalculated between the calls to viewWillAppear: and viewDidAppear:.
You should be able to move your code to viewDidAppear: or turn off Autolayout.

UIViewController workflow management without modal, tabbar and navigationcontroller?

Hello stackoverflow fellows!
Please consider an UI workflow in iOS:
One main viewcontroller and several other viewcontrollers branching out from there:
mainviewcontroller
+-viewcontroller 1
+-viewcontroller 2
+-viewcontroller 3
etc.
I would like to be able to switch and switch back from the main viewcontroller to one of the other viewcontrollers AND also switch BETWEEN the other viewcontrollers.
All iOS patterns I know of seem to be problematic for that usecase:
UITabbarController would be the right choice if I could make the
tabbar disappear - it doesn't fit to the design. I was able to hide
the bar, but the viewcontroller screens don't resize themselves and
the whole thing feels hackish.
UINavigationController is designed for a sequential order of
screens, also the slide-in animation doesn't fit to the design
Modal viewcontrollers are also meant for a sequential order, additionally I have to keep
track of how many viewcontrollers are on the stack. Also, there is a
timing problem with dismissing a view controller and immediately
presenting the next one.
I could just switching views within a viewcontroller I guess, but the
viewcontrollers have all kinds of subtasks to do. I would end up with
one huge viewcontroller and lots of methods embedded for the
different views.
My question:
What would be the best approach to manage a bunch of viewcontrollers in any order I would like to?
Thanks for any help!
I would have a main UIViewController. That one would have references to the other three UIViewControllers. You can then do something like this from inside your main UIViewController:
[self.view addSubview:view1.view];
This works, but I wouldn't advise you doing because it's not the natural way of doing it. As stated by apple:
You should not use view controllers to manage views that fill only a
part of their window—that is, only part of the area defined by the
application content rectangle. If you want to have an interface
composed of several smaller views, embed them all in a single root
view and manage that view with your view controller.
Ok, my solution is not perfect, but seems to work:
Create a UINavigationController.
Use the viewcontrollers: method to add a stack of viewcontrollers to your liking.
When switching between viewcontrollers, rebuild the stack and attach again.
Problem: You only have the navigation controllers animation (slide in/out) at your disposal.
But you can disable the navigationcontrollers animation, get the next viewcontrollers view, animate that in with a UIView animation, then switch to the view controller itself through stack building as explained above.
Really far from perfect, but works.

Only direct subviews of the MainWindow view gets orientation set by iOS?

Whenever my app is rotated, only the viewController of which I've added his view as a subview to the mainwindow gets his interfaceOrientation property updated, the rest remains ignorant of the fact the device has been rotated.
Is it my responsibilty to notify other objects of the change, and if so, what's a nice way to do it?
I've looked into setting interfaceOrientation of my children-viewcontrollers but that's readonly.
Thanks in advance,
I found that calling
willRotateToInterfaceOrientation
and/or
didRotateFromInterfaceOrientation
of the view controller you are going to show worked for me. In my case I was using a Navigation Controller so it was easy to keep track of what was going to be shown to the user next. Below is some code from my project.
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
[viewController willRotateToInterfaceOrientation:
[self interfaceOrientation] duration:0];
}