Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you programmatically change the style of a UITableView after it's been created? [duplicate]

Tags:

(This is about programatically swapping the style of existing tableview and not about setting table view style programatically)

I have a situation where I used a grouped table view in a view this table is editable and whenever it goes to editable view it gets displaced so what I thought was to change its style to plain whenever it goes to editing mode.

Is this possible? (Thanks in advance.)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  static NSString *MyIdentifier = @"MyIdentifier"; MyIdentifier = [NSString stringWithFormat:@"Cell %d",indexPath.row];    // MyIdentifier =@"tblCellView";     NSString *offendersImagePath = [self applicationDocumentsDirectory];     //NSLog(@"%@", dbPath);     offendersImagePath=[offendersImagePath stringByAppendingPathComponent:@"Images"];   CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if(cell == nil) {     [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];     cell = aCustomCell;     aCustomCell=nil; } 
like image 363
Ankit Sachan Avatar asked May 06 '11 10:05

Ankit Sachan


People also ask

How do I change the tableView style programmatically in Swift?

You cannot change the tableView style once set. So the only way is set the style during initialisation.

What is the difference between plain and grouped UITableView?

A plain-style table view is an unbroken list; a grouped table view has visually distinct sections.

How do I populate UITableView?

There are two main base ways to populate a tableview. The more popular is through Interface Building, using a prototype cell UI object. The other is strictly through code when you don't need a prototype cell from Interface Builder.


1 Answers

No this is not possible See this is wriiten in apple documentation:-

You set the table style when you initialize the table view (see initWithFrame:style:). You cannot modify the style thereafter.

So you can not modify it afterwards...

like image 86
Gypsa Avatar answered Oct 27 '22 22:10

Gypsa