جهاز اي فون 3.1 SDK فواصل المحاذاة العمودية من UITableViewCellStyleValue1 textLabel

StackOverflow https://stackoverflow.com/questions/1408105

  •  05-07-2019
  •  | 
  •  

سؤال

يمكن لأي شخص تقديم تفسير التالية الظاهرة ؟

كما من جهاز اي فون 3.1 SDK, لقد وجدت أنه إذا كان UITableViewCell هو من نمط UITableViewCellStyleValue1 و detailTextLabel.text هو غير المعينة ، ثم textLabel لا يتم عرض في وسط الخلية كما هو متوقع.

أحد أبرز التحذير هو أن هذا يحدث فقط بالنسبة لي عندما أنا اختبار على الجهاز – اي فون محاكاة 3.1 SDK يعرض الخلايا بشكل صحيح.أيضا, هذه ليست مشكلة عند استخدام جهاز اي فون 3.0 SDK.

أدناه هو بسيط UITableViewController فرعية تنفيذ هذا يوضح المشكلة.

@implementation BuggyTableViewController

#pragma mark Table view methods


// 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] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    }

    switch (indexPath.row) {
  case 0:
   cell.textLabel.text = @"detailTextLabel.text unassigned";
   break;
  case 1:
   cell.textLabel.text = @"detailTextLabel.text = @\"\"";
   cell.detailTextLabel.text = @"";
   break;
  case 2:
   cell.textLabel.text = @"detailTextLabel.text = @\"A\"";
   cell.detailTextLabel.text = @"A";
   break;
  default:
   break;
 }

    return cell;
}

@end
هل كانت مفيدة؟

المحلول

بدلا من

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];

حاول استخدام

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

نصائح أخرى

أنا أيضا لدي نفس المشكلة.الخلية بدا على ما يرام في محاكاة ولكن عندما ركضت التطبيق على الجهاز الخليوي النص لم يكن محورها عموديا.باستخدام UITableViewCellStyleDefault حل عمودي محاذاة توسيط المشاكل.لحسن الحظ زنزانتي لا الترجمة.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top