TableView corner radius different in iOS6 - objective-c

I have a simple app with a grouped UITableView. On the far left of each cell I have a thumbnail image and have manually created the top and bottom images to have curves to match the corners of the grouped table view.
This has worked well until iOS6. It appears the radius is slightly different which leaves me with gaps.
So that I can keep it looking consistent between iOS5 and 6, is there a way to alter the corner radius? I've tried altering the cell.backgroundView.layer.cornerRadius but it makes no difference.
Any help would be much appreciated!

Have you tried putting this after the cornerRadius?
cell.backgroundView.clipsToBounds = YES;
Setting this value to YES causes subviews to be clipped to the bounds of the receiver. If set to NO, subviews whose frames extend beyond the visible bounds of the receiver are not clipped. The default value is NO.
UIView Class Reference

Related

Circle shaped, dynamic view with AutoLayout

Before AutoLayout I could do a view cut to a circle shape with setting .layer.cornerRadius to half of the view's height.
Now, using AutoLayout how can I achieve, to my view keep look like a circle?
I have already tried and failed:
using KVO to find out when frame changes. It gets called, but at that point setting cornerRadius on the view does not have any effect
calling -setNeedsLayout to have frame values before I set cornerRadius (does not work either)
You need to set the property masksToBounds on the layer.
xyz.layer.masksToBounds = YES;
Further, the reason why this actually won't affect Auto Layout is because the view's frame will remain the same regardless of its corner radius.

How to use Auto-Layout properly in this case?

I have a UIView and a UITableView. I'm trying to align them in a way so they are sticked to each other. The UIView has a fixed height and I want the UITableView to consume the rest of the horizontal space.
I applied a set of constraints which got me pretty close to what I want to achieve but there's a problem that I don't know how to solve. The layout is OK in the portrait orientation but there's a gap between the two elements in the landscape mode. Please see the screenshots below.
Here are the constraint setups for the elements.
UITableView: (all constants are set to 0)
UIView: (all constants are set to 0 except for Height)
Thanks in advance.
I had the same issue of that space appearing above the top cell of a UITableView.
Like yourself, I looked into the constraints and the properties of the table, though the only way I could fix the issue was to delete the UITableView altogether and re-insert it.
Once re-inserted the gap was gone.

Sticking a UIView to the bottom of a UICollectionView that works in 3.5 and 4 inches

I am trying to stick a UIView, containing an ADBannerView, to the bottom of my UICollectionView that works in both 3.5 and 4". My current implementation works for 4" but it gets cut off in 3.5".
3.5"
4"
Storyboard
Constraints
My constraints are essentially setup as: height = 50, space to the left, right and bottom of the screen = 0. As a test, I tried the same constraints on a separate UIViewController and it works as expected. The same constraints doesn't seem to be working in an UICollectionView.
Assuming your collectionView has leading/trailing/top/bottom constraints of 0 to its superview, which will ensure that the collectionView always occupies and is contained by the full screen.
You can then add leading/trailing/bottom constraints of 0 and height of 50 to the bannerView with respect to its superview (the collectionView). And because the collectionView will be constrained to always be fullscreen, without bleeding off, you know that the bannerView will always occupy the bottom 50 pixels of the screen too.
OR
You can add leading/trailing/bottom constraints of 0 and height of 50 to the bannerView with respect to its superview (the viewController (NOT the collectionView)) so that it really has nothing to do with the collectionView, instead it's just pinned to the bottom of the encompassing view.
Two approaches that should yield the same result.
Hope this helps!
Update
Adding an observation from my comment below:
I also now am noticing that your bannerView is a subview of a cell. This is probably not what you intend, right? (ie you dont want a banner for every cell). It should probably be a subview of the collectionView, or better yet the encompassing UIViewController...

Objective C: Adaptive Toolbar On Orientation Change

I am having a problem with my toolbar when i change the orientation of my iPad.
i set my nib file into landscape and everything is all right but when i turned it to portrait my toolbar still has the width from the landscape orientation.
how will i make my toolbar adaptive to the orientation change to portrait?
Landscape:
Portrait:
thanks!
Try adding UIViewAutoresizingFlexibleWidth to the toolbar autoresizingMask like so:
myToolbar.autoresizingMask |= UIViewAutoresizingFlexibleWidth
Or, if your doing this in the Interface Builder, make sure this horizontal bar is selected (others may be selected as well, which is fine):
More from the UIView Class Reference about autoresizingMask:
When a view’s bounds change, that view automatically resizes its
subviews according to each subview’s autoresizing mask. You specify
the value of this mask by combining the constants described in
UIViewAutoresizing using the C bitwise OR operator. Combining these
constants lets you specify which dimensions of the view should grow or
shrink relative to the superview. The default value of this property
is UIViewAutoresizingNone, which indicates that the view should not be
resized at all.
When more than one option along the same axis is set, the default
behavior is to distribute the size difference proportionally among the
flexible portions. The larger the flexible portion, relative to the
other flexible portions, the more it is likely to grow. For example,
suppose this property includes the UIViewAutoresizingFlexibleWidth and
UIViewAutoresizingFlexibleRightMargin constants but does not include
the UIViewAutoresizingFlexibleLeftMargin constant, thus indicating
that the width of the view’s left margin is fixed but that the view’s
width and right margin may change. Thus, the view appears anchored to
the left side of its superview while both the view width and the gap
to the right of the view increase.
If the autoresizing behaviors do not offer the precise layout that you
need for your views, you can use a custom container view and override
its layoutSubviews method to position your subviews more precisely.
In addition to adjusting the flexible width of your toolbar you could create 2 arrays of toolbar items. One for portrait and one for landscape. Fortunately you only have to create the toolbar items once and just add them to the appropriate array(s).
Then during the orientation change you can set the toolbar's items array to the appropriate one.
Good Luck

Resizing an NSView smaller than its subviews?

Couldn't find anything on the net about this and wondered if anyone on SO has a solution.
I have an NSView with several subviews that are centered by removing the left and right anchor points. When I resize my view, programatically or with the mouse, to a smaller width than the subviews: it pushes them off center. Has anyone come across this before and do you have a solution?
EDIT: I want to be able to resize my view to a zero width. The reason being, the view is actually part of a split view and I have hooked up a button to 'collapse' it. When it collapses all of the subviews are pushed off-center and aren't re-centered when the view is resized, effectively un-collapsing it.
I have solved my problem now and thought I would share incase anyone comes across this issue in the future.
No amount of playing with autosizing options or view layouts in Interface Builder seemed to stop my subviews from getting moved off center. I did manage to find this link here and from this page, the advice:
Springs and struts, as currently
implemented, are really no good for
anything but keeping either one or
both sides of a view "stuck" to the
nearest edge. Any sort of centering
behavior, division of gained/lost area
between multiple views, etc. has to be
done by hand.
Based on this I overrode my view's setFrame: method and manually laid out my subviews using their setFrame: method. This works great and gives me the results I'm looking for.
There is the same issue using NSSplitView, resizing here one Subview to be smaller than the Subview Subviews makes sense,e.g. having small charts in the upper subview, and an rss reader in the lower subview.
If you want to show only the rss reader in the lower subview, you can "hide" the upper subview, but after resizing the upper subview the NSImageView are not layed out the same as in the beginning. Check this nib/xCode Project and the following screenshot to see this behaviour.
Only workaroung is to override the resize function to stop getting smaller.