0

解決が難しい問題があります。

UITableView上の表のセルをクリックすると、新しいセルが開くはずです。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

ChoiceChampionViewController *choiceChampionViewController = [[ChoiceChampionViewController alloc] initWithNibName:@"ChoiceChampionViewController" bundle:nil];

NSString * ind = @".....";
NSString * number = ..;
ind = [ind stringByReplacingOccurrencesOfString:@"XX" withString:number];
[[NSUserDefaults standardUserDefaults] setValue:number forKey:@"Region"];
choiceChampionViewController.url = ind;
[self.view addSubview: choiceChampionViewController.view];
}

ChoiceChampionViewControllerは次のように構成されています。

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {        
        champion = [[NSMutableArray alloc] init ];
        self.navigationItem.title = @"Here is some text to make the navBar big";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    dispatch_async(kBgQueue, ^{
        NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
        [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
    });
}

- (void)fetchedData:(NSData *)responseData {
   Method for process data
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [champion count];
}

- (UITableViewCell *)tableView:(UITableView *)atableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    League * app = [[League alloc] init];
    app = [champion objectAtIndex:[indexPath row]];
    cell.textLabel.text = app.title;

    return cell;
}

しかし、それは私にこのエラーを出し続けます: [ChoiceChampionViewController tableView:cellForRowAtIndexPath:]: 割り当て解除されたインスタンスにメッセージが送信されました。手伝いましょうか?

4

1 に答える 1

0

その new を開くUITableViewControllerか、 forUIViewControllerを使用して次のように new に移動します...pushViewControllerUIViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;{

    ChoiceChampionViewController * choiceChampionViewController = [[ChoiceChampionViewController alloc]initWithNibName:@"ChoiceChampionViewController" bundle:nil];
    UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = _backButton;
    [_backButton release],
    _backButton = nil;

    [self.navigationController pushViewController:choiceChampionViewController animated:YES];
    [choiceChampionViewController release];
}

アップデート :

メソッドにもこの次の構造を使用しcellForRowAtIndexPath:ます...

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    }
    League * app = [[League alloc] init];
    app = [champion objectAtIndex:[indexPath row]];
    cell.textLabel.text = app.title;

    return cell;
}
于 2013-08-05T12:06:07.993 に答える