Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot clear previous selected images #291

Open
Soe-Sandi opened this issue Oct 11, 2020 · 0 comments
Open

Cannot clear previous selected images #291

Soe-Sandi opened this issue Oct 11, 2020 · 0 comments

Comments

@Soe-Sandi
Copy link

Soe-Sandi commented Oct 11, 2020

Hi guys... I'm having a problem with clearing auto selected previous images. Here's my code

`class CustomPhotoPickerViewController: TLPhotosPickerViewController {

var maxSelectedCount: Int = 0

override func viewDidLoad() {
    super.viewDidLoad()
    
    selectedAssets = []
    
    var configure = TLPhotosPickerConfigure()
    configure.numberOfColumn = 3
    configure.maxSelectedAssets = maxSelectedCount
    self.configure = configure
    
}

override func makeUI() {
    super.makeUI()
    self.customNavItem.leftBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .stop, target: nil, action: #selector(customAction))
    self.customNavItem.rightBarButtonItem = UIBarButtonItem.init(title: "Done", style: .done, target: nil, action: #selector(onDonePhotoPicked))
    
}
@objc func customAction() {
    self.delegate?.photoPickerDidCancel()
    self.dismiss(animated: true) { [weak self] in
        self?.selectedAssets = []
        self?.delegate?.dismissComplete()
        self?.dismissCompletion?()
    }
}

@objc func onDonePhotoPicked() {
    self.delegate?.dismissPhotoPicker(withPHAssets: [])
    self.dismiss(animated: true) { [weak self] in
        self?.selectedAssets = []
        self?.delegate?.dismissComplete()
        self?.dismissCompletion?()
    }
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    selectedAssets = []
}

func onChangeMaxSelectionCount(newCount: Int) {
    self.maxSelectedCount = newCount
    self.configure.maxSelectedAssets = newCount
    self.configure = configure
    self.reloadInputViews()
}

}I tried to assign empty array toselectedAssetproperty and debugged the value of selected images. Even though my debugged value is showing0 element`, I'm still having previously selected images. Please help and thanks in advanced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant