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 08-17-2010, 04:16 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 60
racharambola5 is on a distinguished road
Default Problem when trying to develop contacts like app on iphone

Hi,

I am trying to create a contacts like app for iphone where the name of contact is displayed on the top (to do this I am writing code in viewForHeaderInSection) and then the details follows in the grouped section. The problem is I am retrieving the values from database and if the first name is null it is displayed on the table. I want to delete the null values and display the fields which has values in it. The names are saved in an array. I am trying to get the following fields from the database to display on the table.

NSMutableArray *nameSectionDetails=[[NSMutableArray alloc]initWithObjects:[eachContact objectAtIndex:0], [eachContact objectAtIndex:1], [eachContact objectAtIndex:2],[eachContact objectAtIndex:3],[eachContact objectAtIndex:4],[eachContact objectAtIndex:19],nil];
NSMutableDictionary *nameSection = [[NSMutableDictionary alloc]initWithObjectsAndKeys: nameSectionDetails, @"name", nil]; self.labelSection=nameSection;

eachContact has all the details of a particular contact.

This is where I am trying to display

- (UIView *)tableViewUITableView *)tableView viewForHeaderInSectionNSInteger)section {
if(section == 0) {
// create the parent view that will hold 1 or more buttons
UIView* buttonView = [[[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 100.0)]autorelease];

UILabel *updateDeletedLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 60.0)] autorelease];
/*updateDeletedLabel.text = [NSString stringWithFormat:@"%@\n%@ %@\n%@\n%@",[eachContact objectAtIndex:1],[eachContact objectAtIndex:3],[eachContact objectAtIndex:2],[eachContact objectAtIndex:3],[eachContact objectAtIndex:4],[eachContact objectAtIndex:19]];*/
/*for(int i=1;i<[[labelSection objectForKey:@"name"]count];i++)
{
if([[[labelSection objectForKey:@"name"]objectAtIndex:i] isEqualToString:@"(null)"])
[[labelSection objectForKey:@"name"]removeObjectAtIndex:i];
//i+=i*i;

}*/


updateDeletedLabel.text=[NSString stringWithFormat:@"%@ %@ %@\n%@\n%@\n%@",[[labelSection objectForKey:@"name"]objectAtIndex:1],[[labelSection objectForKey:@"name"]objectAtIndex:3],[[labelSection objectForKey:@"name"]objectAtIndex:5],[[labelSection objectForKey:@"name"]objectAtIndex:7],[[labelSection objectForKey:@"name"]objectAtIndex:9],[[labelSection objectForKey:@"name"]objectAtIndex:11]];

updateDeletedLabel.font = [UIFont systemFontOfSize:12];
updateDeletedLabel.numberOfLines = 0;
updateDeletedLabel.lineBreakMode = UILineBreakModeWordWrap;
updateDeletedLabel.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
[updateDeletedLabel setTextAlignment: UITextAlignmentCenter];

// add the button to the parent view

[buttonView addSubview:updateDeletedLabel];

return buttonView;
}
return nil;
}
Can anyone please help me in this regard. I am a newbie learning iphone applications and if you can suggest any other method, I am glad to know that. Thanks!!!
racharambola5 is offline   Reply With Quote
Reply

Bookmarks

Tags
development, iphone, iphonesdk, uitableview

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: 348
5 members and 343 guests
freewind, givensur, lendo, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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