Skip to content

Instantly share code, notes, and snippets.

@g001613001
Last active December 22, 2016 11:05
Show Gist options
  • Save g001613001/948b9d874a9a6734754dfddf0fb3934e to your computer and use it in GitHub Desktop.
Save g001613001/948b9d874a9a6734754dfddf0fb3934e to your computer and use it in GitHub Desktop.
func handleTapGesture(_ recognizer: UITapGestureRecognizer) {
if recognizer.state == .ended {
let point = recognizer.location(in: recognizer.view)
if let indexPath = tableView.indexPathForRow(at: point) {//得到indexPath
if indexPath.section == 0 {
if inApp.Visible{
if ( inApp.ticketings.count > 0 || inApp.Month.count > 0 ) {
if indexPath.row == (inApp.ticketings.count + inApp.Month.count) {
if selectedRow >= 0 {
let selIndexPath = NSIndexPath(row: selectedRow, section: indexPath.section)
buyTicketType(indexPath: selIndexPath)
}
} else { // 勾選
if let cell = tableView.cellForRow(at: indexPath) as? MyTicketTVCell {
let pointInCell = recognizer.location(in: cell)
if (cell.lbTicketingName.frame).contains(pointInCell) {
selectedRow = indexPath.row
tableView.reloadData() //// 這裡勾選
setPID(indexPath: indexPath as NSIndexPath)
} else if (cell.imgTicketing.frame).contains(pointInCell) {
selectedRow = indexPath.row
tableView.reloadData() //// 這裡勾選
setPID(indexPath: indexPath as NSIndexPath)
}
}
}
}
view.endEditing(true)
}else{
view.endEditing(true)
if let cell = tableView.cellForRow(at: indexPath) as? MyTicketTVCell {
let pointInCell = recognizer.location(in: cell)
if (cell.btnConfirm.frame).contains(pointInCell) {
api2012_IPassVerify(iPass: cell.tfIPassNum.text!)
}
}
}
} else {
view.endEditing(true)
if let cell = tableView.cellForRow(at: indexPath) as? MyTicketTVCell {
let pointInCell = recognizer.location(in: cell)
if (cell.btnConfirm.frame).contains(pointInCell) {
api2012_IPassVerify(iPass: cell.tfIPassNum.text!)
}
}
}
}
}
}
func buyTicketType(indexPath : NSIndexPath) {
// 執行VC
//performSegue(withIdentifier: "IAP", sender: indexPath)
//return
// original use View
let maxInt = inApp.ticketings.count + inApp.Month.count + 1
let ticketDetailView = Bundle.main.loadNibNamed("TicketDetailView", owner: self, options: nil)?[0] as! TicketDetailView
ticketDetailView.tvDescription.text = "注意事項:\n凡付費後即無法更改,亦不符合七天鑑賞期退費規定,恕無法退換票。所有影片版權歸高雄市電影館所有,請勿未經授權轉錄,拷貝,重置影片。影片串流限定台,澎,金,馬地區,購買前請斟酌。"
ticketDetailView.didTapBuy = {
self.requestProductInfo()
self.blockUI(true)
}
UIApplication.shared.keyWindow!.addSubview(ticketDetailView)
ticketDetailView.constraintToFit(toView: UIApplication.shared.keyWindow!)
if inApp.ticketings.count > 0 {
if indexPath.row < inApp.ticketings.count {
//特別影展票
let ticket = inApp.ticketings[indexPath.row]
//ticket.log()
ticketDetailView.lbDate.text = ticket.Date
ticketDetailView.lbTitle.text = "\(ticket.Name) \(ticket.FormattedPrice)"
} else if indexPath.row >= inApp.ticketings.count && indexPath.row < maxInt {
//雲端戲院月票
let month = inApp.Month[indexPath.row-inApp.ticketings.count] as FilmFestival
//month.log()
ticketDetailView.lbTitle.text = "\(month.Name) \(month.FormattedPrice)"
}
} else {
//雲端戲院月票
let month = inApp.Month[indexPath.row-inApp.ticketings.count] as FilmFestival
//month.log()
ticketDetailView.lbTitle.text = "\(month.Name) \(month.FormattedPrice)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment