Iphone 优化UITableView
我有一个UITableview,由一个从nib加载的自定义单元格组成。这个自定义单元格有9个UILabel,仅此而已。在我的iPhone上滚动表格时,表格的滚动运动有点急促,不像其他表格视图那样平滑!在模拟器上,它可以很好地滚动,但我想它使用了我的mac电脑的额外功能 是否有任何提示可以帮助优化此或任何tableview或方法来帮助找到瓶颈 非常感谢 更新:Iphone 优化UITableView,iphone,uitableview,Iphone,Uitableview,我有一个UITableview,由一个从nib加载的自定义单元格组成。这个自定义单元格有9个UILabel,仅此而已。在我的iPhone上滚动表格时,表格的滚动运动有点急促,不像其他表格视图那样平滑!在模拟器上,它可以很好地滚动,但我想它使用了我的mac电脑的额外功能 是否有任何提示可以帮助优化此或任何tableview或方法来帮助找到瓶颈 非常感谢 更新: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return [[fetchedResultsController sections] count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
//Returns the title for each section header. Title is the Date.
id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
NSArray *objects = [sectionInfo objects];
Data *myData = [objects objectAtIndex:0];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterLongStyle];
NSDate *headerDate = (NSDate *)myData.dataDate;
NSString *headerTitle = [formatter stringFromDate:headerDate];
[formatter release];
return headerTitle;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *dataEntryCellIdentifier = @"dataEntryCellIdentifier";
DataEntryCell *cell = (DataEntryCell *)[tableView dequeueReusableCellWithIdentifier:dataEntryCellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"DataEntryCell" owner:self options:nil];
cell = self.dataEntryCell;
self.dataEntryCell = nil;
}
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
//Method to setup the labels in the cell with managed object content.
- (void)configureCell:(DataEntryCell *)cell atIndexPath:(NSIndexPath *)indexPath {
Data *myData = [fetchedResultsController objectAtIndexPath:indexPath];
cell.label1.text = myData.data1;
cell.label2.text = myData.data2;
cell.label3.text = myData.data3;
cell.label4.text = myData.data4;
cell.label5.text = myData.data5;
cell.label6.text = myData.data6;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
//Check to see if its in Delete mode
if (editingStyle == UITableViewCellEditingStyleDelete) {
//Delete Object from context.
NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
[context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]];
//Save Context to persitant store
NSError *error = nil;
if (![context save:&error]) {
NSLog(@"Delete Error");
exit(-1);
}
}
}
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Table is not to be manually reordered
return NO;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//Create a detailView instance.
DetailViewController *detailView = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
//Pass selected data to the detailView.
Data *myData = [fetchedResultsController objectAtIndexPath:indexPath];
detailView.myData = myData;
//Push the detailView onto the Nav stack.
[self.navigationController pushViewController:detailView animated:YES];
[detailView release];
}
看一看,它引用了Tweetie的作者。简而言之:手动绘制图形,而不使用子视图
现在可以找到原始的Tweetie文章。看看,它引用了Tweetie的作者。简而言之:手动绘制图形,而不使用子视图
现在可以找到原始的推特文章