objective-c - 使用self.tableview reloadData崩溃的应用程序

标签 objective-c uitableview crash

我正在XCode中用两个TableViewControllers做一个简单的应用程序,单击第一个将您带到第二个输入您的名字的位置,但是我在一行上说“self.tableView reloadData”崩溃了,我该怎么办解决这个问题?
我走到最主要的位置,然后说Thread 1:signal SIGABRT
argv char ** 0xbfffed90 0xbfffed90
* argv char *“/用户/ maciosdeveloping /库/应用程序支持/ iPhone模拟器/7.0.3/Applications/20050884-B77A-47FC-98B6-500B5D44D9FB/EjemploModal.app/EjemploModal” 0xbfffef10
** argv char'/''/'
argc int 1 1

NSMutableArray *alumnos;

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"transicion"]){
    UINavigationController *navigationController=segue.destinationViewController;
    MODetalleViewController *moDetalleViewController =[[navigationController viewControllers]objectAtIndex:0];
    moDetalleViewController.delegate=self;
}
}

- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
alumnos=[NSMutableArray array];
}

-(void)viewDidUnload{
[self viewDidUnload];
alumnos=nil;
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

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

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Alumno";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

// Configure the cell...

cell.textLabel.text=[alumnos objectAtIndex:indexPath.row];
return cell;
}

#pragma mark Protocolo de detalle

-(void)AlumnoDetallesViewControllerDelegateDidCancel:(MODetalleViewController *)controller{
[self dismissViewControllerAnimated:YES completion:nil];
}

-(void)AlumnoDetallesViewControllerDelegateDidSave:(MODetalleViewController *)controller{
[self dismissViewControllerAnimated:YES completion:nil];
[alumnos addObject:controller.nombre.text];
[self.tableView reloadData];
}

最佳答案

-(void)viewDidUnload{
[self viewDidUnload];
alumnos=nil;
}

这将陷入无限循环。正确的[super viewDidUnload]
将解雇代码放在方法的末尾,然后尝试!
-(void)AlumnoDetallesViewControllerDelegateDidSave:(MODetalleViewController *)controller{

[alumnos addObject:controller.nombre.text];
[self.tableView reloadData];
[self dismissViewControllerAnimated:YES completion:nil];
}

关于objective-c - 使用self.tableview reloadData崩溃的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22279788/

相关文章:

ios - 更改事件时区是否会影响共享事件中的其他人?

objective-c - 在 UITextField 中输入数字后,如何使小键盘消失?

iphone - 在查看另一个 TableView 后尝试查看 TableView 时,应用程序崩溃

iphone - 保存 View 问题中的两个 PickerViews?

java - Android ICS MediaPlayer 仅在用于同时播放的变量上崩溃

java - 将 SWT 与 JOGL 结合使用时随机崩溃(竞争条件?)

ios - 关于 UITabBarController,有没有办法在选择新选项卡时强制完全释放 View

ios - 向所有 View 可见的 iOS 应用程序添加顶部栏

swift - 我可以在表格 View 中搜索字幕吗?

iphone - 在 UITableView 中移动单元格时,如何使单元格保持静止?