Padding between UITableViewCell and its subview (UICollectionViewCell) - ios

I've been futzing around trying to get some padding between the bottom of my subview and its container UITableViewCell. I have an xib file, but changes to that don't seem to affect my actual ui (i've had to pragmatically change the tableviewcell height, for example).
I've also tried a few examples on SO regarding adjusting the center value of the subview, but no cigar.
Any ideas?
Thanks in Advance.

So, I decided to just move the individual elements within the inner cell which is less reusable than just adjusting the whole cell, but.. It will do for now!
Cheers.

Related

Using a Big Cell in TableView instead of a ScrollView?

I'm making an app that requires I use multiple custom UIControls in some sort of scrolling view. The control's size depends on the auto layout constraints placed on it. Unfortunately, ScrollView doesn't interact well with AutoLayout and this particular UIControl's sizing.
One potential solution would be to place these controls in a very tall UITableView cell and simply use that cell as a sort of ScrollView.
Besides accessibility, are there any problems with doing this?
I'm new to this so any help is appreciated,
Thanks,
Nick

How to set Table view cell to occupy entire screen?

I am working on a project to get custom news feeds from Bing news. I created a custom table view cell and populated various UI items in it. But I am having a hard time to make it occupy the entire screen, it starts from extreme left and ends on the right, leaving large gap from the right margin as show in the image. Can anyone help me out, how to correctly fix it with a detailed explanation of how constraints work in Table views and Tableview cells.
Here' what it looks like in the simulator
Remove previous constraints and add constraint to your UITableView like as shown in below image.
So you UITableView will have 0 margin from edges.
Create a UITableViewController. Just drag drop a TableViewCell into it. Add identifier for that cell and use it. By default it will occupy the whole screen.
In your case I guess you might have added constraints to UITableView. Here what you should do is pin your UITableView to Top,Bottom,Right & Left or make UITableView's width equal to SuperView.

Adding subview to UICollectionView - disables scrolling

I want to add a subview to a UICollectionView in order to make a left panel that scrolls with the collectionview.
Using
[self.collectionView addSubview:myView]
all touches become disabled and I can no longer scroll the view. I've read that adding a subview to a collectionView like this is bad practice.. is this true? Why does it disable touches from reaching the collectionView event when
userInteractionEnabled = NO
I'm trying to do this: imgur link by grabbing the frame position of the first cell in each section, and adding a dot with to myView with the same y value.
Thanks for any help!
Adding subviews using the addSubview: method to a UICollectionView is very bad practice. It can cause a lot of different problems in the normal behaviour of the CollectionView. It can obstruct the views underneath it, capture the touch events, preventing them from reaching the actual scrollView inside the CollectionView, etc. The subviews added using this method will also not scroll as the other elements in the CollectionView do.
The correct way to do what you want is to implement a new type of UICollectionViewCell for the dots, and compute their locations in the prepareForLayout and layoutAttributesForElementsInRect: methods. Basically you'll have either one or two cells in each row. Which ones will have two rows will be determined by you in the methods I've mentioned.
In fact, Apple's docs have a perfect example that's even more complex than what you're trying you achieve. You should check it out from this link.
May I know the purpose of that scroll view ? Because, if you're looking for a subview that displays only a label or image etc., You can use custom collectionview cell instead if I am not wrong... Hope it helps :) :)

Is it possible set width of UITableView or cells on iPad

Since it's not possible to "hook onto" this and get an answer, and none of the answers do it, I thought I'd ask if anyone ever succeeded in doing it and if so, how.
I've created a New File, selected subclass UITableViewController with XIB, and everything works fine. I can set the height of everything (with delegate methods), but not the frame of anything.
Right now the table is as wide as the iPad and it looks kinda corny with the short titles in each cell - and there is nothing in IB that changes the stretching or layout.
I'd be happy with any solution that causes the cells to shrink horizontally - like margins. I tried scrollview insets in IB, but they only add to the size of the scrollview so it gets bigger than the screen.
I think that you want to subclass UViewController and add a UITableView to it, and make it the size you want in IB.

How to replace the plus/minus button of Grouped UITableView in editing mode?

What i am trying to figure out is to add an UIImageView in front of the grouped UITableView while it is in editing mode, just like the ways plus/minus button behaves. There is hell a lot of footprint to build a room there if we could make use of it.
Is there any solution or workaround?
Thanks in advance!
You should be able to just add a UIImageView as a subview to the table cell and give it a negative left offset to put it outside the cell frame.
The cell may clip to its bounds by default (I don't recall offhand), but if it does, just set the table cell's clipToBounds property to NO.
You must override the UIView method layoutSubviews of your table view and check for the editing state. Then you can redraw the cell to your heart's content.

Resources