多くのトピックを読みましたが、何も機能しません。コードはありますが、セルをクリックすると次のエラーが表示されます:
*** -[ModeViewController tableView:didSelectRowAtIndexPath:]: message sent to deallocated instance 0x764df40
Code:
ModeViewController.h
@interface ModeViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableViewModeSelection;
@end
ModeViewController.m
@implementation ModeViewController
@synthesize tableViewModeSelection;
- (void)viewDidLoad
{
tableViewModeSelection = [[UITableView alloc] initWithFrame:CGRectMake(10, 80, screenRect.size.width - 20, screenRect.size.height - 90) style:UITableViewStyleGrouped];
tableViewModeSelection.dataSource = self;
tableViewModeSelection.delegate = self;
[self.view addSubview:tableViewModeSelection];
}
- (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];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.textLabel.text = [modes objectAtIndex:indexPath.row];
cell.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Selected at row: %i", indexPath.row);
}
何が問題なのですか?
前もって感謝します。