iOS 8.3: hidden table row is still visible in the background - ios

In order to hide a table row in some situations I set its height to 0. It works great but unfortunately I still see the row in the background. Can anybody explain this to me? How am I supposed to solve this? I believe I could switch the cell background color from Default (transparent) to something else but in some cases I might want to get the color from the table view itself (from the background)...

The cell is render beyond the bounds of the cell, you will need to clip the subviews.
Either in Interface Builder thick the clip subviews box of set the clipsToBounds to YES.

Related

UITableViewCell background spanning multiple cells

This is end end result I want:
And this is the thing I tried initially.
This does not work, the cells below/above the cell with the background will overlap or underlap the background depending on when they are added into the tableview (like via dequeue/scrolling).
I am quite OK with this not working, and I believe I can achieve it by other means. For example by adding these backgrounds as views within the tableview itself and moving them based on the content offset or similar ways, maybe adding a background image that is tall with them embedded.
But. I am curious if there are some easier way, just adding the view into the XIB and applying a rotation would be very nice.
The background should be below the text in the other cells as well - this is where the complications comes in.
Anyway. Is this possible in some super-neat way?
What you should do is setting all cell's background to clear, and to set a background to your UITableView or your UIView.
Or, as you suggest, you can add a UIView with a rotation applied, and add it as a subview of your UIView/UITableView, and send it to back with [self.view sendSubviewToBack:backgroundView].

Get button click on UITableView in Swift

I have a simple table view which looks like this
Each button overflows some part to next cell (part of requirement).
I want that overflowing button's click event. How to get that ?
By default its taking it as cell click rather than button click if i click on that overflowing part.
I have created a dummy code which changes button color on click, so it is easy for someone to try it out. same layout.
Thanks
EDIT
Below is the original image , what i am trying to do , for simplicity sake i scaled it down to a button
Lets assume req is u cant change height and cant play around table view separator
You have to implement 'tableView:heightForRowAtIndexpath:` method and return greater value than it has now. Your cells don't have enough height to display buttons fully, and because of that some part of your button hides behind of next cell. You can be convinced easily by checking "Clip subviews" checkbox of your Cell Prototype in the interface builder, and if you will see that buttons will be clipped.
EDIT
Check this: https://github.com/arturdev/test
Subclass UITableView and override hitTest:withEvent: and figure out if point is within the frame of one of the buttons. Return the button if the point is within the frame or just return [super hitTest:point withEvent:event] otherwise.
You can use CGRectContainsPoint and [UIView convertRect/Point:to/fromView:] to make calculation easier.
hitTest:withEvent: is a way for the system to ask the outermost view who will receive the event at a given location.
Make UITableView seperator to None. draw 1 or 2 pixel height label with black background color in cell.
Make cell selection style none in cellForRowAtIndex.
cell.selectionStyle = UITableViewCellSelectionStyle.None
Manage proper autolayout or autoresizing mask.
Just tried with your code.
Download from link
Image

I've added a view within a UITableView and there is a gap between the view and the first cell. How can I remove it?

I've added a view to a tableView and there is a gap between the view which is 44px high and the first cell.
Here's a screen shot from IB:
I've tried a few things such as changing the heightForHeaderInSection's value and also disabled adjust scroll view insets. None of these work properly. The view seems to be within the tableView and scrolls with it.
This is how things are looking in simulator:
Would appreciate some help here as I don't understand what exactly is causing this gap.
Thanks for your time
A great way to debug these types of problems is to set a background color. You could set the cells to red and the view to green. It would then be interesting to see if the red and green edges are flush with no white in between.
Based on your screenshot, it looks like nothing is wrong. And by that I mean it looks about right for a view height of 44 points and a cell immediately beneath it with no separator line above it (so it's hard to tell where one ends and the other begins).

Unable to consistently set size of UITextField

I have a UItableViewController, with a UITextField in each cell, pretty basic. I decided to get a bit fancy and alternate the row colors by setting the background color of the text field.
What I noticed is that the text field background color does not match up with the table rows. The width is shorter and the height and position is wrong too.
I tried setting the dimensions of the frame of the text field in cellForRowAtIndexPath. I also tried the same in willDisplayCell. I also tried to muck around with other frames, like the cell frame, to no avail.
I've had some some luck in setting the text field frame size in layoutSubviews in my UITableViewCell subclass, but it still acts strangely. When the table first displays, everything looks right. I click my edit button, and everything still looks right. I click the done button and I'm back to the old problem with both the width and height too short. Checking in the debugger, I am setting everything to the correct values.
More Information:
I have the same problem with some tables which have UILabels instead of UITextFields. All of the tables have fixed size rows. I initially set up the tables with the interface builder, but I'm trying to set the frame sizes programmatically. I am using the latest and greatest Xcode 5 (5.1.1).
Anyone have any suggestions? Where am I supposed to set the frame size? Is there another object that I should be setting the size of?
Thanks in advance

How to prevent cell turnaround effect?

I'm sorry about I can't upload images because of my low reputation point.
(Screenshots)
http://twitter.com/hseongeon/status/410214108881907712/photo/1
http://twitter.com/hseongeon/status/410214156785029120/photo/1
In most iOS development cases, turnaround effect appears on cells by selecting themselves.
As you can see in my screenshots, however, sometimes the effect make a view's background color and text color what I don't want to be. (like badgeView in my screenshots)
I'd like not to change my badgeView's color when cells are selected.
How to do this?
Thank you in advance.
Set the property selectionStyle on your cell to UITableViewCellSelectionStyleNone. This will prevent any calls to setSelected or setHighlighted on your cell.

Resources