Как исправить смещение ограничения автоматического макета на симуляторе iPad? - PullRequest
0 голосов
/ 11 июля 2020

У меня есть этот код для подкласса UITableViewCell,

final class SettingsTableViewCell: UITableViewCell {
    
    // MARK:- Properties
    var switchControl: UISwitch = {
        let switchControl = UISwitch()
        switchControl.isOn = true
        
        return switchControl
    }()
    
    // MARK: - Initializers
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        commonInit()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK:- Methods
    private func commonInit() {
        layer.isOpaque = true
        backgroundColor = .backgroundColor
        configureSwitchControl()
    }
    
    private func configureSwitchControl() {
        switchControl.addTarget(self, action: #selector(handleSwitchAction), for: .valueChanged)
        addSubview(switchControl)
        switchControl.translatesAutoresizingMaskIntoConstraints = false
        switchControl.rightAnchor.constraint(equalTo: safeAreaLayoutGuide.rightAnchor, constant: -12).isActive = true
        switchControl.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
    }
    
    // MARK:- Actions
    @objc private func handleSwitchAction(sender: UISwitch) {

    }
    
}

Он отлично работает на симуляторе iPhone X,

enter image description here

But on an iPad Pro(9.7-inch) simulator I have this shift,

введите описание изображения здесь

ModalPresentationStyle не является полноэкранным. Есть ли способ исправить это, не меняя константу заполнения?

1 Ответ

1 голос
/ 11 июля 2020

На экране не переключатели, а сама таблица. Но вы не показали этот код.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...