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
Stone Preston
42,016 Pointsadding text to table view when there are errors getting data
Im trying to figure out how i can add a text label or something over the table table view when there are errors getting data, when the cells are empty
So since all the cells of the table view are empty, I want to add some text over them that provides some information so its not an empty screen
I tried
UILabel *errorLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 368, 200, 200)];
errorLabel.textAlignment = NSTextAlignmentCenter;
errorLabel.text = @"some error text";
errorLabel.numberOfLines = 4;
[self.view addSubview:errorLabel];
but that didnt work. any tips? Amit Bijlani
edit:
I also tried
UILabel *errorLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 368, 200, 200)];
errorLabel.textAlignment = NSTextAlignmentCenter;
errorLabel.text = @"some error text";
errorLabel.numberOfLines = 4;
[self.view.superview addSubview:errorLabel];
[self.view.superview bringSubviewToFront:errorLabel];
1 Answer
Raissa de Guzman
645 PointsHi there!
I'd like a little more context here. Are you writing this from a subclass of tableview or did you init a tableview in some other view? Also, where do you mean to add the label? inside the cell or as an overlay on the tableview?