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

Working delay on tableview #17

Closed
satoshinosekai opened this issue Feb 7, 2018 · 1 comment
Closed

Working delay on tableview #17

satoshinosekai opened this issue Feb 7, 2018 · 1 comment

Comments

@satoshinosekai
Copy link

satoshinosekai commented Feb 7, 2018

I use the following code in my project,

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
	let message = dataArray.object(at: indexPath.row) as! Message
	if message.ID == "904" {
		let cell = tableView.cellForRow(at: indexPath) as! ImageATableViewCell
		let configuration = ImageViewerConfiguration { config in
			config.imageView = cell.contentImage
		}
		present(ImageViewerController(configuration: configuration), animated: true)
	} else {
		let cell = tableView.cellForRow(at: indexPath) as!  ImageBTableViewCell
		let configuration = ImageViewerConfiguration { config in
			config.imageView = cell.contentImage
		}
		present(ImageViewerController(configuration: configuration), animated: true)
	}
}

When i click the row, it will work after around 1~10 second,
The weird thing is when i one more tap the screen, function can immediately work,
I also use the same image source test on UICollectionViewController, it's perfect work.

How can i fix that? thanks a lot :)

@satoshinosekai
Copy link
Author

satoshinosekai commented Feb 8, 2018

OK, I fix it use DispatchQueue.main.async {}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
	let message = dataArray.object(at: indexPath.row) as! Message
	DispatchQueue.main.async {
		if message.ID == "904" {
			let cell = tableView.cellForRow(at: indexPath) as! ImageATableViewCell
			let configuration = ImageViewerConfiguration { config in
				config.imageView = cell.contentImage
			}
			self.present(ImageViewerController(configuration: configuration), animated: true)
		} else {
			let cell = tableView.cellForRow(at: indexPath) as!  ImageBTableViewCell
			let configuration = ImageViewerConfiguration { config in
				config.imageView = cell.contentImage
			}
			self.present(ImageViewerController(configuration: configuration), animated: true)
		}
	}
}

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