2015-02-06 14 views
1

이벤트 정보를 표시하는 Apple Watch App을 개발 중입니다. 처음에는 이벤트 목록에 10 개의 이벤트가 포함되어 있습니다. 이제 다음 또는 10 개의 이벤트 정보를 표시하고 싶습니다. (예 : 페이지 생성 및 추가 페이지를 현재 페이지 목록에 동적으로 표시). 사용자가 첫 페이지 오른쪽으로 스 와이프하거나 현재 이벤트 목록의 마지막 페이지 왼쪽에 있습니다. 그렇게 할 수 있습니까? 예, 그렇다면 Plz은 내가 그렇게하는 방법을 알려주십시오.WatchKit 앱에서 웹 API의 데이터로 뷰를 동적으로로드

답변

1

예. 우리는 watchkit에 페이지를 동적으로 추가 할 수 있습니다. 나는이 코드를 사용했다.

// Total pages to display 
NSArray *controllerNames=[NSArray arrayWithObjects:@"PageInterfaceController1",@"PageInterfaceController2",@"PageInterfaceController3",@"PageInterfaceController4", nil]; 

//Content to be passed the pages using context 
NSArray *contexts=[NSArray arrayWithObjects:@"1",@"2",@"3",@"4", nil]; 

[self presentControllerWithNames:controllerNames contexts:contexts]; 
+0

이미 제시된 페이지 기반 탐색 목록에 나중에 페이지를 추가하려고합니다. – Prathamesh

1

당신은 예를 들어

[WKInterfaceController reloadRootControllersWithNames:controllers contexts:contexts];

사용하여 페이지의 이전에 관한 목록을 업데이트 할 수 있습니다

NSArray *controllers = @[@"mainController", @"mainController", @"mainController"]; 

NSArray *contexts = @[@"Context1", @"Context2"]; 

[WKInterfaceController reloadRootControllersWithNames:controllers contexts:contexts]; 

은 초기 WKInterfaceController의 init 방법에서이를 호출해야합니다.