TableView падает - PullRequest
       2

TableView падает

2 голосов
/ 16 июля 2010

по какой-то причине этот UITableView продолжает падать, и кажется, что UITableView не может отображать секундную строку по какой-то причине, но я понятия не имею, почему ... пожалуйста, помогите мне здесь, потому что я понятия не имею, что я могу делать неправильно ..... Спасибо !!

#import "SettingsView.h"

@implementation SettingsView

- (void)viewWillAppear:(BOOL)animated {

   [super viewWillAppear:animated];
   transmissionSetup = [[TransmissionSetupViewController alloc]     initWithNibName:@"TransmissionSetupViewController" bundle:nil];
   transmissionSetup.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
   NSLog(@"%i", [self getMinutes]);
   [self setSeconds:10];
   secondsString = [NSString stringWithFormat:@"%i", [self getSeconds]]; 
   [self.tableView reloadData];
}

 #pragma mark Table view methods

// 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];
    }

   if (indexPath.section == 0) {
       cell.textLabel.text =  @"Every:";
       cell.detailTextLabel.text = secondsString;
    }
    // Set up the cell...

    return cell;
}

@end

Ответы [ 2 ]

1 голос
/ 16 июля 2010

Вы инициализируете свой secondString с помощью строки, автоматически высвобождаемой - поэтому не гарантируется, что она будет действительной вне текущей области.Вам нужно сохранить его при инициализации (и не забудьте выпустить позже)

Я бы посоветовал вам взглянуть на свойства target-c для доступа к ivars.

0 голосов
/ 08 декабря 2012
// try this
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

if (indexPath.section == 0) {
    cell.textLabel.text =  @"Every:";
    cell.detailTextLabel.text = secondsString;
}
// Set up the cell...

return cell;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...