Subclass UITabBar without Storyboard to increase height - ios

To my understanding, the only way to subclass UITabBar (to increase the height) in a UITabBarController is to implement a storyboard and assign the subclass directly via the interface builder.
I was wondering if it would be possible to simply swizzle self.tabBar to our own subclassed tab bar, but that probably wouldn’t work.
Any other ideas? I’m simply trying to increase the height of the tab bar, while not breaking or conflicting with the superview’s constraints.

I think you should go through all the answers given in the following link.
Change UITabBar height
In this example people have given ways to customize height without even subclassing.

Related

UICollectionView bigger than NavigationController

I have a UICollectionView embedded in a NavigationController which in turn is embedded in a ContainerView.
The NavigationController views frame width is correctly 964, but the UICollectionView frame width is still 1024.
I cant set any constraints, I thought it would fill to fit the nav controller, not be larger.
What am I missing?
UPDATE: I am using a UICollectionViewController and I am not using any code for this functionality, all done through the storyboard.
Ok, so I considered vacawamas question of whether it's a uicollectionviewcontroller or a uicollectionview. It prompted me to try the uicollectionview which then allowed me to directly apply constraints and it worked!
I still have no idea why the uicollectionviewcontroller didn't work but I'm learning developing iOS apps seems to involve using a lot of workarounds :(

How to prevent a WKInterfaceController from scrolling?

I have a WKInterfaceController, whose I don't want it to be scrollable, but it seems decided to scroll even when my master group's height and width are set to 1 in Relative to container.
I were thinking that It isn't possible until I see Fitstar and Skype apps.
There is a way - inside Storyboard:
Set the tag: "Fixed to screen edges"
After that, scrolling is disabled for the WKInterfaceController.
Looking and testing around found a solution:
Make sure that in Interface Controller's Attribute Inspector you have the insets set to default
UPDATE:
You need to fit your view, in the <=100% of the view, there's no other workaround, if you have more than that, the WKInterfaceController will scroll automatically.

How to place content withing UIView boundaries

I'm new in the swift/iOS application development, I'm currently working on an app for which I need to create the layout programmatically. My app contains a navigation bar at the top and a UIView object, where I'm rendering the controls. The issue I have is that I'm not exactly sure of the height of the navigation bar, so when rendering some controls are currently bellow the navigation bar, and the user cannot see them.
I could easily set a hard-coded height, but then it doesn't work properly across devices.
My best scenario really would be to get the position of the UIView object and place all I need within those boundaries, or to tell my object (e.g. UILabel) to position relative to the UIView.
Thanks for your help!
You can get the frame of the navigation bar from your UIViewController, which is itself a UIView subclass, thusly:
CGRect navigationFrame = self.navigationController.navigationBar.frame;

Why the layout is different between storyboard and the simulator?

As below image shows, in the storyboard, I put a UIScrollView (say called A) under navigation bar and another UIScrollView (say called B) inside A. B is at the top of A.
However, in the simulator, there is big margin between B and the up bound of A (I didn't use any autolayout or write any code). Can anyone tell me the reason? Thanks.
add the below line in your - (void)viewDidLoad method
self.automaticallyAdjustsScrollViewInsets = NO;
hope it will fix your issue.
Even though you're not using Auto-layout, you have Auto-layout checked on in your Storyboard. Because you do, UIScrollViews and any Subclasses of it (UITableView, UICollectionView, etc.) all automatically adjust for the UINavigationBar height when in a UINavigationController. This is implicit and there's no way to turn it off. The only solution is to "offset the offset" or to move the UIScrollView away from the UINavigationBar.
The big margin size is navigation bar height, try add a top autolayout for your scrollView.

Xcode Interface Builder Height/Width Settings vs. View Controller

I'm having a hard time wrapping my head around how frame properties (height, width, posX, posY) work in terms of setting them in a View Controller vs on the Storyboard (Interface Builder).
For instance, let's say I have a UICollectionView object that I set to have a width of 400 and a height of 800. Then, in my code, I set the frame of that same object to 600 x 400. I haven't really found a consistent behavior. I tried setting the frame in viewDidLayoutSubviews and it sort of worked - but it seem to 'jump' back and forth between that and what was set on the storyboard.
Basically my question is, when do the properties on the storyboard change the UI object? I assume that I just need to know that, and then reset them in the View Controller after the fact. Or, is there a way to set the height and width empty so that I can do it all in the code?
Any insight into this would be very helpful!
If you use AutoLayout in your project then setting frames of the view objects you configured in storyboard won't work. Because after you set the frames, AutoLayout will update frames again which makes the frames set by you not working. If you want detail, you can check this article:Advanced Auto Layout Tools But you can set frames of view objects created programmatically to position them.
You can check if you have turned on AutoLayout in you storyboard file's file inspector. There is one thing though, if you do want to use AutoLayout, be sure to not set view's translatesAutoresizingMaskIntoConstraints to NO. The default value of this property is YES. If you use AutoLayout, this property is set by storyboard for you, because constraints created in storyboard are enough to layout the views.
EDIT:
1) if you are not using AutoLayout then setting frames in code should work as expected.
2) yes you can, a little tricky though. you must create UICollectionView yourself using [[UICollectionView alloc] init] or load it from nib. and then configure cell in IB with a xib file. you can use AutoLayout to layout subviews of cell in xib file. and register the class of cell to UICollectionView or load cell object from nib yourself. then you should calculate the size of every cell and let AutoLayout layout subviews of cells.
although this is easier than layout interface entirely in code, it's still a little complicated. the better way is using AutoLayout. Since not all the layout detail can be done in the design time since some views' frame may be different depending on data. you can make a basic layout with AutoLayout first, then IBOutlet the constraints you want to configure on the fly. and change the constant property of constraint objects later. this way, you can 100% control the layout process and also let AutoLayout do the dirty jobs you don't want to do yourself. I suggest you read official docs of AutoLayout and other good resources about it. The learning curve is steep at first, it may make you want to kill yourself too. But it's really powerful and easy to use. once you figured out how AutoLayout works, it will make your iOS development life much easier.
If you want to set the size of things through code, you could try creating outlets from the storyboard to the View Controller. Then in the View Controller, you can use viewDidLoad or viewDidAppear to set the size properties of your object(s).
viewDidLoad will get called when that view is first created. viewDidAppear will get called each time that view comes back onto the screen (like if you are going back with a navigation controller).

Resources