많은 주제를 읽었지만 아무 것도 작동하지 않습니다. 나는 코드를 가지고,하지만 난 셀을 클릭 할 때이 오류가 얻을 : *** -[ModeViewController tableView:didSelectRowAtIndexPath:]: message sent to deallocated instance 0x764df40
코드 :
ModeViewController.htableView : didSelectRowAtIndexPath - 할당 취소 된 인스턴스에 전송 된 메시지
@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);
}
문제가 될 수 무엇 ?
미리 감사드립니다.
솔루션을 모르지만 사이드 노트, UIViewController 및 @implementation ModeViewController'를주의 깊게 읽습니다. 그들은 유사해야하지 않습니까? '@implementation WoLKiModeViewController' –
Zen
이제는 비슷합니다. 제가 실수를. 그것은'ModeViewController' 여야합니다. –