Most of the views in my app are UITableVlews inside a UIViewController. My App feels like it's lagging when trying to scroll through the tables. I was wondering (1.) if it is better to create the cell objects in the table view, or create them at runtime and add them to the cells subview?
examples:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
case 3:
{
NSNumber *tetherState = [[mobIntDict objectForKey:@"State"] intValue];
NSNumber *currValState = [[NSNumber numberWithInt:1023] intValue];
tetherSw = [[UISwitch alloc] initWithFrame:CGRectMake(197, 8, 94, 27)];
tetherSw.tag = kDefaultSwTag;
if(tetherState == currValState){
tetherSw.on = YES;
}else{
tetherSw.on = NO;
}
[tetherSw addTarget:self action:@selector(tetherSwAction:) forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:tetherSw];
cell.textLabel.text = @"Tether";
[tetherSw release];
}
break;
}
-OR-
-(void)viewDidLoad{
tetherSw = [[[UISwitch alloc] initWithFrame:CGRectMake(197, 8, 94, 27)] autorelease];
tetherSw.tag = kDefaultSwTag;
[tetherSw addTarget:self action:@selector(tetherSwAction:) forControlEvents:UIControlEventValueChanged];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
case 3:
{
[cell addSubView:tetherSw];
}
}