UITextField を持つ tableView でカスタム セルを使用しています
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 24)];
txtField.placeholder = @"<Enter Text>";
txtField.textAlignment = UITextAlignmentLeft;
txtField.clearButtonMode = UITextFieldViewModeAlways;
txtField.autocapitalizationType = UITextAutocapitalizationTypeNone;
txtField.autocorrectionType = UITextAutocorrectionTypeNo;
[cell.contentView addSubview:txtField];
[txtField release];
}
}
これは正常に機能し、UITextField がセルをカバーします。
これを 3.2 SDK または iPad で実行すると、UITextField が左に適切に配置されず、セルが重なって、280 ではなく 270 の UITextField 幅を使用する必要があります UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake (0, 0, 270, 24)];
画素比率がおかしいようです。これはどのように修正できますか?デバイスに搭載されている OS のバージョン (3.1.2、3.1.3、3.2、または 4.0) を特定する方法はありますか、それとも別の方法で実行できますか?
テオさんありがとう