以下是我的示例代码。如何重新加载tblview
(tableview)?请帮帮我。如何重新加载一个表视图行选择然后另一个tableview重新加载?
@interface NewUIViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) NSMutableArray *dataArray;
@property (weak, nonatomic) IBOutlet UITableView *tblview;
- (IBAction)btnAddRow:(id)sender;
@property (weak, nonatomic) IBOutlet UITableView *tblviewProject;
@property (nonatomic, strong) NSMutableArray *projectArray;
@end
@interface NewUIViewController()
{ }
@end
@implementation NewUIViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.dataArray = [[NSMutableArray alloc] initWithObjects:@"Tiger",@"Leopard",@"Snow Leopard",@"Lion",nil];
self.projectArray = [[NSMutableArray alloc] initWithObjects:@"test1",@"test12",@"test1 Leopard",@"test13",nil];];
self.tblview.delegate= self;
self.tblview.dataSource=self;
self.tblviewProject.delegate= self;
self.tblviewProject.dataSource =self;
self.tblviewProject.frame = CGRectMake(50, 150, 600, 600);
}
-(BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger) supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskLandscape);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.tblview)
{
return [self.dataArray count];
}
else if (tableView == self.tblviewProject)
{
return [self.projectArray count];
}
return 0;
}
- (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.editingAccessoryType = YES;
if (tableView == self.tblview)
{
cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
}
else if (tableView == self.tblviewProject)
{
cell.textLabel.text = [self.projectArray objectAtIndex:indexPath.row];
}
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView == self.tblviewProject)
{
NSMutableDictionary *newDic = [[NSMutableDictionary alloc] init];
NSDictionary *rowchange = (NSDictionary *) [self.dataArray objectAtIndex:[self.projIndexPath intValue]];
[newDic addEntriesFromDictionary:rowchange];
[newDic setObject:pname forKey:project];
[self.tblview beginUpdates];
[self.dataArray replaceObjectAtIndex:[self.projIndexPath intValue] withObject:newDic];
[self.tblview reloadData];
[self.tblview endUpdates];
}
}
@end
请使用您的问题下面的“编辑”链接属性格式代码并阅读指导原则。没有人可以阅读你发布的内容,因此对你没有帮助。 –
请添加一个简短的描述,你想要达到什么样的目标,因为你的问题由于语法不好而不清楚。当用户单击第一个表格视图中的一行时,你想重新加载第二个表格视图? –
第二个表格视图点击第一个表格视图重新加载。删除并创建工作正常。但不能替换或更改现有的记录值不会重新加载第一个表。 –