sirisha
sirisha

Reputation: 171

How to display multiple rows in UITableView

I am Sirisha. I am new to developing for iPhone. I want to display multiple rows in a table view (Ex: One 10, Two 15, etc.) Please help me.

Upvotes: 1

Views: 425

Answers (2)

Anju
Anju

Reputation: 524

in view did load should allocate a array for row array rowArray = [NSArray alloc]initWithObjects:@"A", @"B", @"C", nil];

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1; }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [rowArray count];

}

It will return 3 rows with 1 section in a table view

Upvotes: 0

Iqbal Khan
Iqbal Khan

Reputation: 4617

u can do this by using section of table 1st section contain 10 2nd section contain 15

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;       //one section in the table.
}

and then use this method to add number of rows

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
        //number of rows in the section

if section 1 then return 10 if section 2 return 15

Upvotes: 2

Related Questions