저는 스토리 보드를 처음 사용하고 사용자 정의 초기화에 문제가 있습니다. 이로 바뀌 내가 대신 didSelectRowAtIndexPath의 prepareForSegue을 사용하고 스토리 보드와 지금스토리 보드를 사용하여보기 컨트롤러의 사용자 정의 초기화
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//Creating Dummy Hotel
HotelItem *hotel = [[HotelItem alloc] init];
HotelDetailViewController *controller = [HotelDetailViewController controllerWithHotel:hotel];
controller.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:controller animated:YES];
[hotel release];
}
:
스토리 보드를 사용하기 전에 나는 사용자 정의 초기화가있는 테이블에서 뷰 컨트롤러를 밀어이 작업을 수행하는 데 사용
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//Creating Dummy Hotel
HotelItem *hotel = [[HotelItem alloc] init];
hotel.name = @"Hotelucho";
// Make sure we're referring to the correct segue
if ([[segue identifier] isEqualToString:@"ShowSelectedHotel"]) {
HotelDetailViewController *controller = [segue destinationViewController];
}
}
나는 개인 변수 "호텔"을 변경하고 [segue destinationViewController] 직후에 속성을 설정할 수 있다는 것을 알고 있지만 내 사용자 정의 init 메서드를 호출하는 것이 더 유용하다는 것을 알고 있습니다.
이 방법이 있습니까?
하지만. initWithCoder 및 initWithFrame에서 초기화를 수행 한 경우 "controllerWithHotel :"에서했던 것처럼 호텔 변수를 전송하는 방법은 무엇입니까? – Chompas
prepareForSegue :: 메소드에서 컨트롤러 객체의 속성을 설정하기 만하면됩니다. 속성을 설정 한 후 새로 고침해야하는 항목을 새로 고치는 것을 잊지 마십시오. – Adis
그래서 controllerWithHotel과 같은 사용자 지정 Init을 사용할 수 없기 때문에 호텔 속성을 비공개로 유지할 수 없습니다. 맞습니까? – Chompas