Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Diary App Using Core Data Custom UITableViewCell Customizing Table View Cell Appearance

kennedy otis
kennedy otis
3,570 Points

Custom cell with large background image

Hi guys Am trying to make custom cells with large background image with labels on top of those images. Issue is that the images seems to be overlaying and when I click on the cell, the background color for my labels disappear. Am trying to achieve this https://dl.dropboxusercontent.com/u/21316108/Screenshot%202014-05-13%2010.31.03.png Is there something I should know or am missing about UITableViewCell.

8 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

Can you show us your code? :)

kennedy otis
kennedy otis
3,570 Points

Am using storyboard with UITableViewController + CustomTableViewCell. http://pastebin.com/Zb1pgRNR

Thomas Nilsen
Thomas Nilsen
14,957 Points

Could you also post a image of the problem? (I know you explained it, but I'd also like to see it :)

kennedy otis
kennedy otis
3,570 Points

I have managed to solve the overlaying image problem and now is the label background disappearing when i click and also the indexing is not correct. For example when i click on first row i expect index 0 but i see index 1 and when i clicked second row i see index 0 instead of 1.

Before click https://dl.dropboxusercontent.com/u/21316108/b4.png

After click https://dl.dropboxusercontent.com/u/21316108/after.png

Notice the Poster label disappear when clicked

Thomas Nilsen
Thomas Nilsen
14,957 Points

That's because you have used:

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath

When you really want to use

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
kennedy otis
kennedy otis
3,570 Points

Thanks the indexing is now working but the background for my label disppear when clicked..

Thomas Nilsen
Thomas Nilsen
14,957 Points

If you want to be able to click on them - why make UILabels and not UIButtons?

kennedy otis
kennedy otis
3,570 Points

The UILabel and is just appearance thing.. what am really interested with is the index which you have helped me to fix.. I just thought may be having UILabel will be nice but unfortunately when I click on the cell the background colour disappear...

Thomas Nilsen
Thomas Nilsen
14,957 Points

I'm sorry to disappoint you, but I don't have an explanation for that. If I were to guess I'd say the problem is somewhere in the storyboard. The reason I'm saying this is because I've made custom cells several times myself, in code. UILabels were among the UI elements used and they did not disappear when I clicked on them.