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 12-11-2011, 12:48 PM   #1 (permalink)
Tech Genius Developer
 
Join Date: Jul 2011
Posts: 40
vilisei is on a distinguished road
Send a message via Skype™ to vilisei
Default UITableViewSection

I am making an app that has a view that show a table view.
PHP Code:
    SampleTableDataSource = [[NSMutableArray allocinit];
    
// Insert Section here
    
[SampleTableDataSource addObject:@"Cell 1"];
    
// Insert Section here
    
[SampleTableDataSource addObject:@"Cell 2"];
    
// Insert Section here
    
[SampleTableDataSource addObject:@"Cell 3"];
    
// Insert Section here
    
[SampleTableDataSource addObject:@"Cell 4"]; 
PHP Code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
// Return the number of sections.
    
return 4;
}

- (
NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
// Return the number of rows in the section.
    
return [SampleTableDataSource count];

It is setup correctly because it shows the content but instead of showing 4 sections, it show everything 4 times. How do I do I add section because I heard it was different in iOS 5. Also I am using Automatic Reference Counting.
vilisei is offline   Reply With Quote
Old 12-11-2011, 12:58 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

In your cellForRow, you need to check the section number and use different data accordingly.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 12-11-2011, 01:02 PM   #3 (permalink)
Tech Genius Developer
 
Join Date: Jul 2011
Posts: 40
vilisei is on a distinguished road
Send a message via Skype™ to vilisei
Default

Quote:
Originally Posted by Domele View Post
In your cellForRow, you need to check the section number and use different data accordingly.
PHP Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static 
NSString *CellIdentifier = @"cell";
    
    
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (
cell == nil) {
        
cell = [[UITableViewCell allocinitWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    
// Configure the cell...
    
cell.textLabel.text = [SampleTableDataSource objectAtIndex:indexPath.row];
    
cell.detailTextLabel.text = @"Date Created";
    return 
cell;

So I have to make a new array for each section? Isn't there a code like
PHP Code:
[SampleTableDataSource addSection:@"Section 1"]; 
or anything close to that?
vilisei is offline   Reply With Quote
Old 12-11-2011, 02:57 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

No. Perhaps you should read more about table views. The link in my signature is a good start.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

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: 396
12 members and 384 guests
7twenty7, AppsBlogger, David-T, Duncan C, HemiMG, heshiming, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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