我在我的某一行部分中将所选数据显示到 detaillabeltext 中时遇到问题,除了重新加载整个表格视图之外,还有其他方法可以仅重新加载部分的特定行吗?
//RootViewController.m(父控制器)
-(void) selectedData:(NSString*) text
{
selectedAbsenceType = text;
NSLog(@"the absence type select is %@",text);
}
-(void) (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
if (indexPath.section == 0)
{
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
NSDictionary *dictionary = [dataArray objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"data"];
NSString *cellValue = [array objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
if([cellValue isEqual: @"Absence Type"])
{
cell.detailTextLabel.text = selectedAbsenceType;
}
else if([cellValue isEqual:@"Start Date"])
{
cell.detailTextLabel.text = selectedDate;
}
return cell;
}
==================================================== ========================================== 我在调用方法时遇到问题协议,它在这个声明中不断提示我一个 ARC 语义问题
[self.delegate selectedData: (NSString*) [self.absenceTypes objectAtIndex:indexPath.row]];:
//child.h
#import <UIKit/UIKit.h>
@protocol childViewControllerDelegate;
@interface AbsenceTypesViewController : UITableViewController
{
id<childViewControllerDelegate>delegate;
}
@property (nonatomic,weak) id<childViewControllerDelegate> delegate;
@property NSArray *absenceTypes;
@end
@protocol childViewControllerDelegate <NSObject>
-(void) selectedData:(NSString*) text;
@end
//child.m
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *selectedCell = nil;
selectedCell = [self.absenceTypes objectAtIndex:indexPath.row];
[self.delegate selectedData: (NSString*) [self.absenceTypes objectAtIndex:indexPath.row]];
//[self.navigationController popViewControllerAnimated:YES];
NSLog(@"%@", selectedCell);
}