가장 쉬운 방법 :
는 예를 들어, 밀어보기에, 그런 짓을. 의 TableView와의 ViewController에서
: 당신이로 돌아가려면 버튼을 누를 때
- (void)updateRowValue:(NSNotification *)notification{
NSDictionary *valuesDictionary = [[NSDictionary alloc] initWithDictionary: [notification userInfo] copyItems:NO];
NSString *newString = [valuesDictionary objectForKey:@"StringVal"]
}
이, 행 텍스트 필드로의 ViewController 지금
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TextFieldViewController *tfvc = [[TextFieldViewController alloc] init];
[tfvc setPostNotificationString:@"updateRowValue"];
[self.navigationController pushViewController:tfvc animated:YES];
}
을 선택할 때 호출하는 방법입니다 이전의 viewController는 이것을 다음과 같이 호출합니다.
- (IBAction)saveButtonPressed{
NSArray *valuesArray = [[NSArray alloc] initWithObjects:textField.text,nil];
NSArray *keyArray = [[NSArray alloc] initWithObjects:@"StringVal",nil];
NSDictionary *dictionary = [[[NSDictionary alloc] initWithObjects:valuesArray forKeys:keyArray] autorelease];
[[NSNotificationCenter defaultCenter] postNotificationName:[self postNotificationString] object:self userInfo:dictionary];
[[self navigationController] popViewControllerAnimated:YES];
}
첫 번째 라인은별로 실패하지 않거나 미래의 증거가 아닙니다. 'parentViewController'와 같은 것을 명시 적으로 링크하는 것이 더 안전합니다. – jv42
동의. 이렇게하면 루트에 액세스 할 수 있습니다. 루트는 원하는 루트가 아닐 수도 있습니다. – PengOne