Подтвердить что ты не робот

Узнайте родительский вид кнопки с нажатой клавишей быстрого доступа

У меня есть код, в котором у меня есть 3 кнопки, и я бы хотел узнать родительское представление этих кнопок при нажатии

 @IBAction func resizeButtonClicked(sender: UIButton) {
    if(sender.isEqual(resizeButton)) {
        //This is to convert to small square
    } else if(sender.isEqual(maximizeButton)) {
        //This is to convert to maximized view
    } else if(sender.isEqual(closeButton)) {
        //This is to close the view completely

    }
}

Теперь я могу идентифицировать кнопку отправителя, но как определить, как эта кнопка сидит?

Спасибо

Нихилу

4b9b3361

Ответ 1

Попробуйте следующее

sender.superview

Ответ 2

Я не хочу создавать пользовательский класс, а также не хочу использовать accessibilityHin:

    func performAction(_ sender : AnyObject?)
{
    let cell = sender?.superview??.superviewOfClassType(UITableViewCell.self) as! UITableViewCell
    let tbl = cell.superviewOfClassType(UITableView.self) as! UITableView
    let indexPath = tbl.indexPath(for: cell) 
    let myData = myDataArray[indexPath.row]
    ...
}