I'm trying to print a UITableView, but a grey rectangle appears instead.
My UITableView is inside a UIView on my Storyboard and I'm using a custom UITableViewCell
Do you have any idea ?
Here's a gist of my code
Check the tableView background color and your cell background color on your storyboard.
I don't see anything wrong in your code.
Related
I have a fairly complicated UIViewController with a custom UITableView instantiating on top of a Visual Effect & UIImageView. In order to keep the beautiful blur effect throughout the UITableView, I had to set the entire thing's background color (including UITableViewCells and viewForHeaderInSection) to UIColor.clearColor(). The obvious problem (that I can't solve) is that when I scroll up, the text of the UITableViewCell will scroll under the clear background of the viewForHeaderInSection and both text will overlap. Here's a screenshot.
Any thoughts on how I can prevent the UITableViewCell from scrolling under the viewForHeaderInSection? I was playing around with the UITableView's contentInsets but that changes the entire UITableView, not just the UITableViewCell sections. Thx in advance...
1) Select the tableview in storyboard.
2) Select attribute inspector.
3) Change the style from plain to grouped.
Does anybody have the slightest idea on how I can achieve this type of effect on my table view cells?
or do you guys know a blog, Git, Repo that has nice TableViewCell make ups? thanks
In your storyboard, make everything transparent and set those images as your background.
Then you can use '
UIVisualEffectView | UIVisualEffectView with Blur class
' to set those blurs on your custom cells, make sure that your cell's background color is also in transparent mode.
or use
CAGradientLayer Class
to set them up.
If table's cell are static then you can create static custom cell in storyboard, Use Pin option in storyboard set left and right constraint for auto layout. Use background image and UILabel for creating for creating cell.
check the below link, it will help you.
use your own background image and font colur.
Customize UITableView and UITableViewCell
http://www.appcoda.com/ios-programming-customize-uitableview-storyboard/
When I am developing iOS8 Today Extension, I set a UITableViewController as the
main view controller.And I met this problem:
When I init the UITableViewCell using initWithStyle:UITableViewCellStyleDefault
in cellForRowAtIndexPath, the whole area of one cell can trigger didSelectRowAtIndexPath
normally. However when set UITableViewCellStyle to UITableViewCellStyleValue1,
UITableViewCellStyleValue2 or UITableViewCellStyleSubtitle, I can only trigger
didSelectRowAtIndexPath by click in detailTextLabel or imageView's area. Click in other blank
areas will get no respond.
I've tried to set tableview's delegate to self, set detailTextLabel and imageView's
setUserInteractionEnabled:false in cellForRowAtIndexPath, and all these do not work. Does
anyone have any idea about this?
P.S. I am not using storyboard or xib file,just code.
I've found a same problem on Android:
I'd like to click anywhere (blank area) in a list view
I encountered this myself while trying to display UITableView inside the TodayView. Although I don't know why is this happening, I found out that this only occurs when the UITableViewCell background is clearColor. If you set the background to some other color, didSelectRowAtIndexPath will be called. However, here's a quick workaround - put UILabel to stretch on whole area of the cell's contentView and then the delegate method will be called every time. Anyway, it seems like a bug.
Here is how the tableViewCell appears within the TableVIew in the storyboard. The Cell is a custom made cell in the interface builder.
Here is how the same TableView appears live.
Im wondering what is causing the lives Cell white background to be truncated and turned grey. I would like the entire Cell to look the same as it does in the Storyboard.
I'm trying to avoid adding any code to my iOS project that has to do with visual set up since that's what Interface Builder is supposed to streamline for you.
So I'm trying to set up the prototype cell in IB and then just call:
TableCell *cell = [self.tableView dequeueReusableCellWithIdentifier:#"TableCell"];
The problem is if I change the background color for the cell in IB it remains white when I run my application. I can preset the color of the label fine but not the background color attribute in the Table Cell.
As an additional note, I can see that the UIView that is the backgroundView inside the cell is null after breakpointing and inspecting the variable after it's been initialized.
UPDATE
I'm getting the impression that the option for background color in IB is essentially useless? I'd rather not believe that.
You cannot do that unfortunately.
Change the background colour of the cell in tableView:willDisplayCell:forRowAtIndexPath:
From the documentation of UITableViewCell:
Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it.
In interface builder, add a view as a subview of the cell, that will be your background view. You can then add all labels or anything else as subviews to that view. Change that views background color as you want.
I think this is probably a bug in IB. You can add views to that bar at the bottom of the controller, and then connect those views to the backgroundView and selectedBackgroundView properties of the cell. However, the backgroundView's color doesn't work, while the selectedBackgroundView's color does work correctly. If you add a background view in code to a custom table view cell and give it a backgroundColor, that does work.