Accessing grouped UITableView section view? - iphone

Basically I want to "cut the corners" of the first cell imageview and the last cell imageview to match the curved corners on the grouped tableview section.
I was given the advice to do this by setting the view's masksToBounds property to true?
Anyone know how to access this view? Doing cell.superview doesn't work. cell.contentView.superview doesn't work and cell.backgroundView.superview doesn't work.
Anyone have any ideas?

There is no section view. A cell's superview is the UITableView itself.
The rounded corner drawing is done by UITableViewCell's backgroundView, and backgroundView isn't in imageView's view hierarchy (contentView and backgroundView are siblings—their superview is the Cell itself), so unfortunately masksToBounds won't work.

Related

Stop cell from being dragged out of UITableView bounds

I have a UIVIew on which I loaded a UITableView as subview. The tableView is exactly the height of all it's rows(4 of them) heights sumised, about half the height of the main view.
The problem is that when I drag a row to move it I am able to drag beyond the bounds of the table and this cuts my cell's view (I am only able to see the part that is still in the table's bounds).
Is there a property I can change to stop the cell from being dragable out of the table's bounds?
you can do this like below..
[yourtableview setBounces:NO];
let me know it is working or not!!!!
Happy Coding!!!
If the UITableView is exactly the height of the 4 rows . Then you Do Not Need the Scrolling functionality of the UITableView and you can simply stop the scrolling by :-
TableView.scrollEnabled = NO;
Hope this is what you wanted . Please tell otherwise.

Custom UITableViewCell resize label when setEditing is called

Okay here is a picture:
I've got custom UITableViewCell with UILabel.
It's obvious I should resize my custom UILabel in -setEditing method, but how to exactly calculate how much to resize it? And is there efficient way to resize reused cells?
Thanks!
You don't have to do anything in setEditing method if you have the right autoresizing mask:
label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;
So the first question is how are you adding the label to the UITableViewCell? If you are adding it to the cell's view, then that is where your problem begins.
UITableViewCells have a contentView property. This contentView is responsible for resizing its contents when the cell enters editing mode. It knows how to do this. The cell's view property does not. So, first you need to add your UILabel as a subview of the cell's contentView in initWithStyle:. The cell doesn't actually know how big it is in initWithStyle:, though, so you can set the frame of the label in layoutSubviews.
As for resizing the cell, you can do this in tableView:heightForRowAtIndexPath:
In this method, you can check the indexPath of the row and configure the height appropriately.

Height change of UITableViewCell causes resizing of contentView and accessoryView in cell

I'm using this solution to animate a change of height in a UITableViewCell. I've set a UIButton as the accessoryView of the cell, which triggers the height change. The animation works fine, but if the cell gets larger in height, the ratio in width of contentView and accessoryView changes. In specific, the accessoryView gets wider, the contentView narrows. The change of ratio has got the effect, that the UIButton in the accessoryView moves a bit to left. But for me, it should stay in the same x-Position. Anyone got a clue? Thanks for your answers :)
Made a workaround by placing a UIButton in the contentView of the cell. So solved!

Prevent subview from scrolling in a UIScrollView

I have a UIScrollView subclass with a certain subview I'd like to prevent from scrolling (while all the other subviews scroll as normal).
The closest example to this I can think of is UITableView's "index strip" on the right side (look in the Contacts app to see an example). I am guessing this is a subview of the table (scrollview) but it does not move as the user scrolls.
I can't seem to make my subview stay put! How can I accomplish this?
The trick is to adjust the frame of the "non-scrollable" subview inside -layoutSubviews.
Add the view that you want not to move as a sibling view of the scroll view on top of the scroll view instead of as a subview.
You can set it's property called userInteractionEnabled to NO

UIScrollView and CALayers

I have a custom UIView that is composed entirely of CALayers.
In the awakeFromNib method it creates and sets all the CALayers into their appropriate positions (CAGradientLayer, several CATextLayers, and a few custom CALayer subclasses). The custom UIView does not override the drawRect: method because there's no drawing done directly into the view (all of the drawing is done in the sublayers).
So I took this view and embedded it in a UIScrollView. The problem? No scroll bars appear and the view does not scroll. The view is clearly larger than the bounds of the scroll view, and instead of allowing me to scroll, it just cuts off at the scroll view bounds.
What could be wrong here?
You have to set the scrollView's contentSize.