Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-08-2010, 01:34 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 64
algor_angel is on a distinguished road
Question Change Background of an Empty Table View

Hi, I would like to change the background of an empty tableView to show a message/image to say something like "No elements in this view" or whatever text/image I like to show. How do I do that?
algor_angel is offline   Reply With Quote
Old 11-08-2010, 01:40 PM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by algor_angel View Post
Hi, I would like to change the background of an empty tableView to show a message/image to say something like "No elements in this view" or whatever text/image I like to show. How do I do that?
i prefer to add a UILabel on the center of the screen. No needed to change background.

check the number of the rows (or the count of the array that contain the info of the tableview cells) and then enable visible=YES; or NO; of your UILabel
__________________
dany_dev is offline   Reply With Quote
Old 11-08-2010, 02:42 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 64
algor_angel is on a distinguished road
Default

Ok, thank you.

Last edited by algor_angel; 11-08-2010 at 05:26 PM.
algor_angel is offline   Reply With Quote
Old 08-23-2011, 06:24 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 37
ahsan123 is on a distinguished road
Default numberOfRowsInSection

Hello Dany_Dev

Can you tell me that should I display a message in empty table in numberOfRowsInSection method? I have done this in numberOfRowsInSection method:
Code:
if([array count]==0)
	{
		UILabel *message=[[UILabel alloc]initWithFrame:CGRectMake(20, 100, 115, 35)];
		message.text=@"Empty";
		[tableView addSubview:message];
		[message release];
		
	}
But there is no error and nowarning and no expected output either?

Thanks
ahsan123 is offline   Reply With Quote
Old 08-23-2011, 06:35 AM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

add a NSLog....checking that array.count is really 0 and if tableView is not nil....
__________________
dany_dev is offline   Reply With Quote
Old 08-23-2011, 06:49 AM   #6 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 37
ahsan123 is on a distinguished road
Default Not printing in log

Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
	if([array count]==0)
	{
		NSLog(@"%d",[array count]);
	}
}
ahsan123 is offline   Reply With Quote
Old 08-23-2011, 07:08 AM   #7 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

yes....and so? when I said add a NSLog i mean also to check its input and the other things I said....
__________________
dany_dev is offline   Reply With Quote
Old 08-23-2011, 09:21 AM   #8 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 37
ahsan123 is on a distinguished road
Default Thanks Worked but

Thanks dany_dev

It workrd when I wrote [[NSMutable array]retain] and removing [[NSMutable arrayWithObjects:@"",nil]retain]

but my question is will it make difficulties when enter new data?
because I could not enter data from another view "it is not displaying".

If you could tell me I'll be really thankful but thanks anyways.
ahsan123 is offline   Reply With Quote
Old 08-23-2011, 09:28 AM   #9 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

I don't understand your question.
__________________
dany_dev is offline   Reply With Quote
Old 08-23-2011, 09:31 AM   #10 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 37
ahsan123 is on a distinguished road
Default

I mean will enter new data in the array if I did this:

[[NSMutableArray array]retain]
ahsan123 is offline   Reply With Quote
Reply

Bookmarks

Tags
background, table view, tableview background

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 340
10 members and 330 guests
7twenty7, chiataytuday, condor304, Creativ, Domele, dreamdash3, laureix68, LEARN2MAKE, mistergreen2011, Paul Slocum
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,660
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, laureix68
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0