2017-03-08 4 views
1

두 개의 버튼과 tableView가있는 대화 상자를 팝업하는 버튼이 있습니다. 사용자 정의 UIView를 사용하여 tableView가 표시되고 UITableViewCell도 사용자 정의됩니다. UITableViewCell은 사용자 정의 확인란과 UILabel로 이루어져 있습니다. 탭을 클릭하면 checkbox에 표시되는 행을 클릭 할 수 있도록 탭 제스처를 tableView에 추가하려고합니다. 내가 더 후 3 초 동안 누르면이 기능은 좀 작품 만있는 UITableViewCell 내가이 오류를 일으키는 원인을 모르는이Swift UiTableViewCell 내 메인보기 컨트롤러에서 길게 누르기 후 재설정

UITableViewCell Error ScreenShot

으로 재설정합니다. 어떤 도움을 주시면 감사하겠습니다. 난 당신이 탭 제스처를 추가해야 할 수도 있습니다 생각

override func viewDidLoad() { 
    super.viewDidLoad() 

    ...code 

    let tap = UITapGestureRecognizer(target: self, action: #selector(tableTapped)) 
    self.tableView.addGestureRecognizer(tap) 
} 

func tableTapped(tap:UITapGestureRecognizer) { 
    let location = tap.location(in: self.tableView) 
    let path = self.tableView.indexPathForRow(at: location) 
    if let indexPathForRow = path { 
     self.tableView(self.tableView, didSelectRowAt: indexPathForRow) 
     print("Tapped on the table") 
    } else { 
     // handle tap on empty space below existing rows however you want 
    } 
} 

답변

0

다음있는 tableView 내 사용자의 UIView에

func locationButtonPressed(sender: UIBarButtonItem) { 
    // Create a custom view controller 
    let vc = RadiusViewController(nibName: "RadiusViewController", bundle: nil) 
    // Create the dialog 
    let popup = PopupDialog(viewController: vc, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true) 

    // create first button 
    let cancelButton = CancelButton(title: "Cancel", height: 60, dismissOnTap: true) { 
     print("Popup Canceled") 
    } 

    // create second button 
    let okButton = DefaultButton(title: "Ok", height: 60, dismissOnTap: true) { 
     print("Ok button pressed") 
    } 

    // add buttons to dialog 
    popup.addButtons([cancelButton, okButton]) 

    // present dialog 
    self.present(popup, animated: true, completion: nil) 

    print("location button pressed") 
} 

탭 제스처 기능 : 여기

팝업 대화 상자를 엽니 다 내의 ViewController 내 코드입니다 tableviewcell, tableview 않습니다.

+0

어떻게하면됩니까? – satish99

0

사용자는 ViewController에 UITableViewDelegate를 구현하기 만하면됩니다. didSelectRowAtIndexPath에 대한 콜백 메소드가 있으며 사용자 정의 체크 박스와 같은 셀 속성에 액세스 할 수있는 로직을 설정할 수 있습니다. 탭 제스쳐 인식기는 기본적으로 제공되는 기능이므로 필요하지 않습니다.

UITableViewDelegate Documentation