2013-10-23 4 views
0

iReporter 자습서 응용 프로그램의 코드 일부를 http://www.raywenderlich.com/에서 사용하고 있습니다.UITableView 시작하는 방법

-(void)refreshStream { 
    //just call the "stream" command from the web API 
    [[API sharedInstance] commandWithParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:@"stream", @"command", nil] onCompletion:^(NSDictionary *json) { 
     //got stream 
     [self showStream:[json objectForKey:@"result"]]; 
    }]; 
} 

내가있는 tableview로 JSON에서 결과를 넣을 수 있습니다 방법 :

은 내가 StreamScreen.m이 코드를 얻었다. scrollview 대신 tableview를 사용하고 싶습니다.

+0

체크 아웃 내 ANSW를 어 .... – Jitendra

+0

@ user2908800 귀하의 질문이 실제로 [JSON] (https://en.wikipedia.org/wiki/JSON)에 관한 것이라면,주의 깊게 제목과 태그를 지정해야합니다. –

답변

0

json 데이터를 배열로 가져옵니다. objectForKey를 사용하고 tablview 방법

이하 사용 tablview으로 데이터를 묶고

<UITableViewDelegate,UITableViewDataSource> 

하는 .m 파일이이 코드를 삽입이

.H 파일처럼 .H에서 tablview 대리자와 소스를 선언

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
    { 

      return 1; 

     } 

    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 

      return [stream count]; 


     } 

     -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
     { 


      AppDelegate * delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate]; 

      static NSString *CellIdentifier = @"Cell"; 
      cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
      if (cell == nil) 
      { 
       cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 

      } 
      cell.textLabel.text=[stream objectAtIndex:indexPath.row]; 
      return cell; 


} 

이 코드를 시도 ....

관련 문제