문제

내비게이션 컨트롤러를 사용하여 새로운보기를 푸시하고 IT의 제목을 동적으로 설정하고 있습니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int countryIndex = [indexPath indexAtPosition: [indexPath length] - 1];
NSString *selectedCountry = [[countrysData objectAtIndex: countryIndex] objectForKey: @"title"];
scheduleState *scheduleStateViewController = [[scheduleState alloc] initWithStyle:UITableViewStyleGrouped];

[self.navigationController pushViewController:scheduleStateViewController animated:YES];    
scheduleStateViewController.title = selectedCountry;    

[scheduleStateViewController release];

CountryData는 XML 피드에서 생성 된 변이 가능한 배열입니다.

이제 다음보기로 이동하면 올바르게 표시되지만 새 ViewController 내부에서 NSLOG를 수행하려고하면 (NULL)을 기록합니다.

NSLog(@"The title is: %@", self.navigationItem.title);

2009-10-27 11 : 30 : 20.416 MyApp [50289 : 20B] 제목은 다음과 같습니다.

웹 서비스 쿼리를 잡기위한 매개 변수로 제목을 사용해야합니다 ...

이견있는 사람?

도움이 되었습니까?

해결책

컨트롤러에 제목을 기록하려는 경우 -viewDidLoad 또는 비슷한 것, 제목을 설정하기 때문에 실패합니다. ~ 후에 보기 컨트롤러를 밀어 넣습니다. 컨트롤러 제목을 푸시하기 전에 제목을 설정하면 더 잘 작동해야합니다.

그것이 nil 일 수있는 유일한 이유는 selectedCountry 변수는 nil입니다. 직접 로그를 확인하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top