2013-04-15 1 views
-3

임있는 tableview 많은 데이터 셀을 만들 수 있습니다 나는 무엇을이 같은 객체의 여러 셀의 tableview를 만들 수 있다는 사실을 알고 원하는 방법 :의 tableview에서아이폰의 새로운

NSMutableArray *animal = [[NSMutableArray alloc]initWithObjects:@"Lion",@"Tiger",@"Dog",@"Cat",@"Sheep",@"Wolf", nil]; 

그에 FO 셀을 클릭 할 때 사자 1, 사자 2, 사자 3, 사자 4, 사자 5, ...)

그래서 첫 번째 객체의 많은 객체와 함께 tableview 인 tableview는 tableview를 다른 tableview에 생성하고 싶습니다.

나를 안내 해주세요. 감사!!! 방법은 아래 테이블보기의 방법

#pragma mark - 
#pragma mark TableView data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    // Return the number of sections. 
    return 1; 
} 


    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
     // Return the number of rows in the section. 
     return animal.count; 
    } 


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

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    cell.textLabel.text = [array objectAtIdex:indexPath.row]; 

    return cell; 
} 

다음

답변

0

사용하면 jQuery과에서 행을 선택하면 화재 작업에 사용됩니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
     // Create Object of you SecondViewController for go on. 
    SecondViewController *tlController = [[SecondViewController alloc] init]; 
    tlController.animalName = [array objectAtIndex:insexpath.row];// here you need to pass name of animal on SecondViewController, and in SecondViewController you need to display animal name related to pass from previous view controller. 

    [self.navigationController pushViewController:tlController animated:YES]; 

} 
+0

UITableView 내가 다음 페이지에 대해 무엇을 감사에게 도움이 .May 여기에 질문을 게시하기 전에 더 나은 연구를하십시오 ??? 다음 페이지는이 테이블보기입니다. – janatan

+0

@ janatan- 내 코드에서 마지막 방법으로 확인하십시오. – iPatel

+0

SQLDb이게 무엇입니까? – janatan

0

먼저 tableview의 데이터 소스를 설정하고 xib를 통해 위임해야합니다.

이제 하나의 대리자 메서드가, 당신의 tableview에 numberofrows를 반환

  • (NSInteger)있는 tableView : (jQuery과 *)있는 tableView numberOfRowsInSection : (NSInteger) 섹션 {}

여기에서 animal.count를 반환 할 수 있습니다. 어레이에 10 개의 객체가 있으면 10 개의 셀이 생성됩니다.

> 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell 
    *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; 
     if (cell == nil) { 
       cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyIdentifier"] autorelease]; 
      cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     } 

     cell.textLabel.text = [animal objectatIndex:indexpath.ro]; 
     return cell; 
} 

동물 배열에있는 개체가있는 tableview가 반환됩니다. 그런 다음 선택한 행의 세부 정보를 얻으려면 한 가지 방법, didselectrowatindexpath가 있습니다. 인터넷 검색을 시도하십시오. 그게 ...입니다;)는