我的 UITableviewcell 子类中有一个 IBaction,我很难让它重新加载 tableview 的数据。它看起来很简单,但我尝试了很多员工,但没有任何效果。
以下是我在 UITableviewcell 中使用的代码,但没有重新加载:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (IBAction)deleterow:(id)sender
{
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Delete content ?"
message:@"Do you want to delete ?"
delegate:self
cancelButtonTitle:@"Cancelar"
otherButtonTitles:@"Eliminar", nil];
[message show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if ([title isEqualToString:@"Eliminar"])
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"datatesting.plist"];
libraryContent = [[NSMutableArray alloc] initWithContentsOfFile:path];
[libraryContent removeObjectAtIndex:0];
NSLog(@"delete the Row:%@",libraryContent);
[libraryContent writeToFile:path atomically:YES];
UITableView *parentTable = (UITableView *)self.superview;
[parentTable reloadData];
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
从 UITableviewcell 重新加载数据的最佳方法是什么?