(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(@"%@", db开发者_高级运维Path);
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;
}
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...
I dont think you can change the style of UITableView dynamically and set to plain or grouped. I think you have to do that while initializing it
-(id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
Another possible solution would be to have multiple UITableViewCell prototypes and switch them whenever necessary.
精彩评论