2011-04-06 3 views
5

내가 UITableViewCell 및 UItableView 하나의 view.UnableView의 특정 행을 클릭합니다, 그것은 anotherViewController.But에 navigate to navigate to otherViewController.But를 탐색 할 수 없습니다 UITableViewCell 클릭 . 어떻게 이럴 수 있을까 ?? jQuery과에 대한UITableViewCell 및 UITableView otherviewcontroller 내비게이션

이 코드를 사용하고 있습니다 :

 

- 
-(void)pushView1:(id)sender{ 
    if(edController == nil) 
    edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]]; 
    [self.navigationController pushViewController:edController animated:YES]; 
} 
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    UITableViewCell *tbcel; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    tbcel.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

    tbcel.layer.cornerRadius = 15; 
    tbcel.text = aBook.Name; 
    switch(indexPath.section) 
    { 
     case 0: 
      cell.text = aBook.Address; 
      break; 
     case 1: 
      cell.text = aBook.Phone; 
      break; 
     case 2: 
      cell.text = aBook.Purchase; 
    } 
    return cell; 
} 


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(edController == nil) 
    edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]]; 
    [self.navigationController pushViewController:edController animated:YES]; 
}![enter image description here][1] 

내가있는 UITableViewCell을 위해 무엇을해야합니까?

ist is tableviewcell and below it in block is tableview

+1

UITableViewCell은 바로 테이블보기의 일부입니까? 그렇다면 별도로 조치를 취해야하는 이유 – visakh7

+0

Tableview에 포함되지 않은 UiTableViewCell은 View Through 인터페이스 빌더 라이브러리에 별도로 삽입됩니다. – Ketan

+0

IB 또는 기타에서 온 것이 든 상관 없습니다. UITableViewCell이 목적이 아닙니다. 아래 내 대답을 참조하십시오. – Xiao

답변

1

편집 :

당신이 밀어 원하는 것은 또 다른 뷰의있는 UITableViewCell

없습니다.

당신은

YourCustomView *view = [[YourCustomView alloc] init]; 
[self.navigationController pushViewController:view animated:Yes]; 

을 말할 수 있지만 코드가 다른 세포에 전달 볼 수 없습니다.

셀은 UITableView의 모양을 사용자 정의하는 데 사용됩니다.

는 추가 :

나는 if 문이 여기에 유용하지 않다 생각합니다.

if(edController == nil){ 
    edController = [[EditableDetailCell alloc] initWithnibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]]; 
    [self.navigationController pushViewController:edController animated:YES]; 
} 

뜻 또는 빈 뷰는 어떤 방법으로 전달 될 예정이다.

+0

나는 내 쿼리 plz cgeck을 다시 편집했다. – Ketan

+0

나는이 tableviewcell (고객 2)에 대해 pushview1 메서드를 시도했지만이 메서드로 탐색하지는 않았다. – Ketan

+0

IBAction으로 만들고이 메서드를 올바른 단추로 연결 했습니까? 인터페이스 빌더? 사진 옆에있는 고객 2가 바로 버튼입니까? – Xiao

1
(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSLog(“Selected Row %d”, indexPath.row); 
    YourNextViewController *objVC = (YourNextViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ViewControllerIdentifier"]; 
    [self presentViewController: objVC animated:YES completion:nil]; 
} 
관련 문제