【发布时间】:2010-02-15 13:14:39
【问题描述】:
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView setRowHeight:100];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.view setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
}
#pragma mark -
#pragma mark Table view data source
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 3;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 100) reuseIdentifier:CellIdentifier] autorelease];
// For Name/Phone:
UITextField *name = [[[UITextField alloc] initWithFrame:CGRectMake(75, 22, 200, 25)] autorelease];
[name setFont:[UIFont systemFontOfSize:14]];
[name setPlaceholder:@"John Doe"];
[name setReturnKeyType:UIReturnKeyDone];
[name setAutocapitalizationType:UITextAutocapitalizationTypeWords];
[name setAutocorrectionType:UITextAutocorrectionTypeNo];
[name setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
UITextField *phone = [[[UITextField alloc] initWithFrame:CGRectMake(75, 67, 200, 25)] autorelease];
[phone setFont:[UIFont systemFontOfSize:14]];
[phone setPlaceholder:@"0412 123 123"];
[phone setReturnKeyType:UIReturnKeyDone];
//[phone setKeyboardType:UIKeyboardTypePhonePad];
[phone setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
UIImageView *background = [[[UIImageView alloc] initWithFrame:CGRectMake(9, 11, 302, 89)] autorelease];
background.image = [UIImage imageNamed:@"book-personaldetailsbg.png"];
// Add to the View
[cell addSubview:background];
[cell addSubview:name];
[cell addSubview:phone];
// Add actions:
[name addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];
[phone addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];
}
return cell;
}
这是有原因的吗?我只设置了几个对象,所以我几乎看不出它为什么会滞后。它跳了起来,它不是我的手机,因为设置应用运行良好。
【问题讨论】:
-
在模拟器中可以正常工作吗?
-
是的,在模拟器中完美运行。在 3GS 上也很好用。它并没有慢到让应用程序无法使用,它只是有明显的延迟,这真的很烦人 - 如果修复它会带来更好的用户体验。
-
估计每个单元格的高度也可能有相同的效果,请检查这个话题stackoverflow.com/questions/21577976/…
标签: iphone iphone-sdk-3.0 uitableview