我正在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/