Black corners on UITableView Group Style - iphone

I have a problem where my UITableView (group style) has a black "tip" above it's rounded corner.
I'm setting up the background of the tableview like so:
[meetingTableView setBackgroundColor:[[UIColor alloc] initWithPatternImage:[[UIImage alloc] initWithContentsOfFile:#"background.png"]]];
And my table view ends up looking like this:
black pointy edge on rounded corner http://papernapkin.org/pastebin/resource/images/imageEntryId/6487
Any ideas how I can get rid of those black points?

I have got the same problem.
When I set clear color by xib, I have the back corner
The solution is to set it by code !
(The same problem with interface builder exist for webviews)

Try this in your controller's viewDidLoad method:
meetingTableView.backgroundColor = [UIColor clearColor];

You'll get Black corners on UITableView Group Style if you set background color to clear color in XIB.
Instead try this code for removing Black corners on UITableView Group Style
tableViewObject.backgroundColor=[UIColor clearColor];

Just in case you weren't already aware, there's another neat technique you can use to make customized backgrounds for UITableViews:
Not quite as simple as setting the background as you're doing, but it gives you a lot more flexibility and can scale to any table size.

Maybe if you put yourTableViewOutlet.backgroundView=nil;

To avoid the black corners you have to make sure that the UITableViewCells are not opaque. It looks like you're using custom styles table cells and the default value for opaque is YES. Either go to Interface Builder and uncheck the opaque checkbox if the table cell was set up in a XIB file. Or use the setOpaque:NO setter to change value.
Because the table cell view still has a rectangular frame even with the rounded corners the cell view and not the actual table view is causing those black corners.

My guess is that it's related to something that you're doing in your custom table view cells. You might want to experiment with setting the cell background color to [UIColor clearColor].

I think you should set the background color of your table as clearColor and initialsie your view with the background image.
Then it will definitely not show the black corners. But also don't forget to set the background color of your cell as white color

The up-voted answer above (set the tableView's background to [UIColor clearColor]) may not work for you if you are like me and never use the UITableViewController, instead putting a UITableView inside a UIViewController.
In this case it's not the tableView that needs to have a clear background, but the view that holds the tableview.
This is not intuitive, but it works for me. In interface builder you can just set the parent view's background color to clear color, or you could do the same in code in viewDidLoad with:
self.view.backgroundColor = [UIColor clearColor];
I'm guessing the reason for the black corners is something about the internal graphics optimization, and setting the background clear fixes it.

Related

Subclassing UITableViewCell for grouped table

I'm trying to create a a custom subclass of a UITableViewCell to be used in a grouped table.
I'm laying out the subclass with a nib. (I've just tried doing it without the nib but getting the same problem).
Whenever I've done this before I've wanted to create a whole new cell style with a different background etc... so in awakeFromNib I do this...
- (void)awakeFromNib
{
// N.B. I am not doing this, this is how I normally get rid of border
// in this case I want the border so I am not running this code.
self.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
self.backgroundColor = [UIColor clearColor];
}
but in this case I want to keep the background with the rounded corners and I'm just adding different UI elements to it.
The cell gets created and all the elements are laid out correctly but I'm getting an annoying "second border" in the top left corner of every section.
I have a screen shot showing this.
At first I thought this was a hair on my screen or something but it isn't.
I've tried setting the backgroundView and backgroundColor but that removes the normal cell background and I want to keep them.
Any ideas how I can get rid of this?
EDIT
Just to clarify what I said above about setting backgroundColor and backgroundView.
Here is what happens when I change them...
In this I set the backgroundView to nil. The border remains but so does the little bit I'm trying to get rid of.
If I set the backgroundView to a new UIView then this happens...
I want the same background with the white background and the rounded corners border. Just not with that annoying little bit.

UITapGestureRecognizer on transparent view

I have a tree with views where the highest level view is transparent and contains either an image or a label (with a transparent background).
When attaching a UITapGestureRecognizer to this view, I only get notifications on the views which contain images.Also, if I leave the view empty, then I get events only when the background color is different than [UIColor clearColor].
I have done a dump and the entire view tree has userInteractionEnable = YES.
How can I get the UITapGesturerRecognizer to work on the view with a transparent background?
Solved
Problem was not what I thought. The transparent views were in a scroll view and during initialization they were outside of the view's visible area. Those within the visible area work ok.
Wild guesses here, but if you include a 1x1 pixel image in the view, would that view then qualify for gestures?
Another equally wild guess would be to add a transparent image to the view and try that.
Try giving the view a nearly-transparent background color, like [UIColor colorWithWhite:0 alpha:0.01].
Try setting the background color to whatever except the clearColor and setting the alpha property to 0.0;
myView.backgroundColor = [UIColor blackColor];
myView.alpha = 0.0;

Black corners around UITableViewCells

I am trying to display a UITableView in front of an image, and here's the steps I'm following:
Inside the view, add a UIImageView with the image set to the appropriate file in the project
Add a UITableView inside the parent view (the same parent as the image view)
Set the backgroundColor for the table view to clear
Wire up a datasource in the view controller to display some test data
Hook up the data source in IB.
After doing this, the tableviewcells have a black background in the corners. It isn't coming from any of the parent views as far as I can tell. I have a test project at bitbucket which demonstrates the issue.
Jeff Lamarche ran into the exact same issue today and put up a blog post about it:
http://iphonedevelopment.blogspot.com/2010/08/transparent-grouped-tableviews.html
Basically, there appears to be some bug where you still need to add this in code (even though you already have the tableView set to be clear in Interface Builder):
self.tableView.backgroundColor = [UIColor clearColor];
To remove the black edges just go to ur .m file and in ur viewDidLoad method add a line
tableName.backgroundColor = [UIColor clearColor];
and thats it no more ugly UI
As stated in Jawboxer's answer, you need to set the background colour in code:
self.tableView.backgroundColor = [UIColor clearColor];
But also ensure that the background colour in Interface Builder is set to the default "Group Table View Background Color". I had it as "Clear Color" in IB and it still wasn't working, until I reset it to the default.
The root cause of why you must set the clear color in code is here: Black corners on UITableView Group Style

Is there a way to fix the background image of a UITableView

I have set the background of my UITable with a custom image.
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];
The problem I'm having is the background image is scrolling and doesn't look good at the top and bottom of the screen where you see the image being joined.
Is there a way to fix the position of the background image and just have the table scroll over the top of it?
Insert a UIImageView behind the UITableView. Set the UIImageView's image to background.png. Use [UIColor clearColor] as the table's background.
You need to put a UIImageView beneath your table view, set the table view's background color to clear (or in IB, set the opacity property of its background at 0). Then construct your CELL views to have clear areas that your background image can be seen through. You can do that programmatically or in IB (it's easier to visualize in IB, but the code to hook it all together is a bit tricky).

How to change a grouped UITableView cell's background to black (or non-white)?

Just want to make sure I'm not overlooking something obvious... It seems like it should be trivial to set the background color (black is fine) of a UITableView's cell to something other than white or completely transparent so that you can display your data with white text. However, with my attempts I lose the corners on my grouped table view and it all looks like crap.
I've seen & understand the methods described by Matt Gallagher about customizing TableView cells with exotic gradients, etc. but wanted to be certain before heading down that path...
I believe that the rounded corners of the Grouped style are actually backgrounds of the table cells. Thus you can't just replace the white part, because it's not solid color with drawn border - it's ImageView acting as backgroundView for the cell (using different graphics depending of the cell row and number of rows in section).
So either you try with your own graphics so you can keep the roundness (I'm trying something out for myself, not fully figured yet) or set each cell.backgroundView to nil and use cell.backgroundColor = [UIColor blackColor];
If you edit the cell.backgroundColor instead of the cell.contentView.backgroundColor it should work for you.