Я новичок в прошивке и я перед проблемой относительно показать строку в предыдущей ячейке Tableview в том же UIViewControllerКак добавить текущую строку в предыдущем Tableview из UIAlertAction в объективных с
Как показан на изображениях
Когда я нажимаю на ок я хочу, чтобы добавить полный вместо метки
Когда я добавляю строку в cellforrowatindexpath, она получает замену во всей ячейке tableview. Я хочу заменить текст ярлыка в соответствии с выбранным индексом. Мой код выглядит следующим образом.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView == customaudittable)
{
static NSString *[email protected]"STI";
AuditTableViewCell *cell = (AuditTableViewCell *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:STI];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AuditTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.accessoryType=UITableViewCellAccessoryNone;
}
cell.audittitlelbl.text=[NSString stringWithFormat:@"%@",[idarray objectAtIndex:indexPath.row]];
cell.auditdesclbl.text=[NSString stringWithFormat:@"%@",[namearray objectAtIndex:indexPath.row]];
return cell;
}
if(tableView == FPNtable)
{
static NSString *[email protected]"STI";
FPNTableViewCell *cell = (FPNTableViewCell *)[tableView dequeueReusableHeaderFooterViewWithIdentifier:STI];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FPNTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.accessoryType=UITableViewCellAccessoryNone;
}
cell.fulllbl.text=[NSString stringWithFormat:@"%@",[idarrayFPN objectAtIndex:indexPath.row]];
return cell;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView == Audittable)
{
NSString *listString;
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
listString = [defaults objectForKey:@"ListString"];
AuditTableViewCell *cell = (AuditTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.listlbl.text=listString;
midString =[NSString stringWithFormat:@"%@",[midarray objectAtIndex:indexPath.row]];
[self serverconnectionFPN];
// Audittable.alpha=0.24;
UIViewController *controller = [[UIViewController alloc]init];
CGRect rect;
if (idarrayFPN.count < 4) {
rect = CGRectMake(0, 0, 272, 160);
[controller setPreferredContentSize:rect.size];
}
else if (idarrayFPN.count < 6){
rect = CGRectMake(0, 0, 272, 300);
[controller setPreferredContentSize:rect.size];
}
else if (idarrayFPN.count < 8){
rect = CGRectMake(0, 0, 272, 200);
[controller setPreferredContentSize:rect.size];
}
else {
rect = CGRectMake(0, 0, 272, 250);
[controller setPreferredContentSize:rect.size];
}
alert =
[UIAlertController alertControllerWithTitle:@"AuditCheckList"
message:@""
preferredStyle:UIAlertControllerStyleAlert];
FPNTable = [[UITableView alloc]initWithFrame:rect];
FPNTable.delegate = self;
FPNTable.dataSource = self;
[controller.view addSubview:FPNTable];
[controller.view bringSubviewToFront:FPNTable];
[controller.view setUserInteractionEnabled:YES];
[FPNTable setUserInteractionEnabled:YES];
[FPNTable setAllowsSelection:YES];
[alert setValue:controller forKey:@"contentViewController"];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
[Audittable reloadData];
}];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
}
if (tableView == FPNTable) {
FPNTableViewCell *cell = (FPNTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.circleimg.image=[UIImage imageNamed:@"CircleClick.png"];
NSString *ListString;
ListString =[NSString stringWithFormat:@"%@",[idarrayFPN objectAtIndex:indexPath.row]];
NSLog(@"List Item =%@",ListString);
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
[defaults setObject:ListString forKey:@"ListString"];
}
}
-(void) tableView:(UITableView *)tableView didDeselectRowAtIndexPath:
(NSIndexPath *)indexPath {
FPNTableViewCell *cell = (FPNTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.circleimg.image=[UIImage imageNamed:@"Circleicon.png"];
}
Спасибо заранее!
Но я Я смущаюсь, в каком методе таблицы? – Muju
, когда я устанавливаю его в cellforrowatindexpath, его значение задано во всей ячейке. Я хочу установить только ячейку, которую я выбрал. – Muju