3.1.3 и 3.2 различное поведение

Я использую пользовательскую ячейку в tableView с UITextField

- (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 не выравнивается должным образом по левому краю, перекрывая ячейку, и я должен использовать ширину UITextField 270 вместо 280 UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 270, 24)];

Кажется, что-то не так с соотношением пикселей. Как это можно исправить? Есть ли способ определить версию ОС на устройстве ( 3.1.2, 3.1.3, 3.2 или, может быть, даже 4.0) или это можно сделать другим способом?

Спасибо Тео

0 ответов

Другие вопросы по тегам