Open thedc89 opened 8 years ago
how did u fix it? I'm running through the same problem with Swift 3
Solution:
let buttonCallback:MGSwipeButtonCallback = {
(sender: MGSwipeTableCell!) -> Bool in
self.pageTextField.isHidden = false
self.pageTextField.respectiveCellNumber = (indexPath as NSIndexPath).row
self.pageTextField.becomeFirstResponder()
self.customControl.isHidden = true
self.view.bringSubview(toFront: self.pageTypeView)
return true
} as! MGSwipeButtonCallback
let btn:MGSwipeButton = MGSwipeButton(title: "", icon: img, backgroundColor: nil, insets: ins, callback: buttonCallback
@thedc89 Thanks for your solution. However, I am getting a Thread 1: EXC_BAD_INSTRUCTION
for the as! MGSwipeButtonCallback
when my TableView is loaded. Did you experience this? I hope this awesome Git gets a proper Swift 3 conversion soon.
Oh, I get this same error! I have to reopen the issue
this works for me:
let buttonCallback:MGSwipeButtonCallback = {_ in
self.pageTextField.isHidden = false
self.pageTextField.respectiveCellNumber = (indexPath as NSIndexPath).row
self.pageTextField.becomeFirstResponder()
self.customControl.isHidden = true
self.view.bringSubview(toFront: self.pageTypeView)
return true
}
Both solutions did not work for me. I'm still initiating both of the buttons inside the array like
cell.leftButtons = [MGSwipeButton(title: "Delete", backgroundColor: UIColor.red, callback: {
(MGSwipeTableCell) -> Bool in
self.messages.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
print("Delete!")
return true
}),MGSwipeButton(title: "More",backgroundColor: UIColor.lightGray, callback: {
(MGSwipeTableCell) -> Bool in
// -- More button clicked
print("More!")
return true
})]
I changed a bit syntax from "(sender: MGSwipeTableCell) -> Bool" to "_ -> Bool", now cells appear but on click the app will be crashed on AppDelegate EXC_BAD_INSTRUCTION - any more ideas?
I've pushed 1.5.6 version with Swift interoperation improvements. The swift 3.0 sample is ready too ;)
https://github.com/MortimerGoro/MGSwipeTableCell/tree/master/demo/MailAppDemoSwift
I'm facing the same issue @jarkoAndroid. I've implemented both the solutions and also studied the example by @MortimerGoro. My cells load but the moment I click on them, the app breaks.
Any thoughts on fixing this? I'm running my app on iOS 10. Anything I'm missing?
@Shoshin23 can you send me a testcase project with the issue? I couldn't reproduce this in the demos or in any of my apps. Also tried with iOS 10.0.
@MortimerGoro I'm pasting the exact code snippet below. Do tell me what i'm missing.
let swipeToCard = MGSwipeButton(title: "", icon: DataService.resizeImage(UIImage(named: "swipeArrow")!, newWidth: 24), backgroundColor: UIColor.yellow) { (MGSwipeTableCell) -> Bool in
let indexPath = self.tableView.indexPath(for: MGSwipeTableCell!)
self.performSegue(withIdentifier: "oneLinerShow", sender: indexPath)
return true
}
Returns a following error:
How to edit it to make it work?