[YogaKit] IOS Screen rotation doesn't invalidate the layout ok #557

Closed
opened 2017-05-18 06:14:59 -07:00 by Daij-Djan · 3 comments
Daij-Djan commented 2017-05-18 06:14:59 -07:00 (Migrated from github.com)

Report

IOS Screen rotation doesn't invalidate the layout. The layout is wrong after rotation.
I tested this with the sample app and added an additional applyLayout call in didLayoutSubviews of the VC (see code below)

to summarize the two issues:

  1. layout that gets created in viewDidLoad is different from layoutSubviews
  2. layout after rotation to an orientation is different than the layout if vc was opened with the orientation

difference is ~ 1px :)

# Report IOS Screen rotation doesn't invalidate the layout. The layout is wrong after rotation. I tested this with the sample app and added an additional applyLayout call in didLayoutSubviews of the VC (see code below) ## to summarize the two issues: 1. layout that gets created in viewDidLoad is different from layoutSubviews 2. layout after rotation to an orientation is different than the layout if vc was opened with the orientation - [x] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate AFAICS difference is ~ 1px :)
Daij-Djan commented 2017-05-20 11:26:22 -07:00 (Migrated from github.com)

I changed the container size and moved calling applyLayout to didLayoutSubviews.
BUT this results in a different layout than before though....

I added this to the sample:

	override func viewDidLayoutSubviews() {
		let root = self.view!
		let layout = root.yoga
		
		let newContainerSize = self.view.bounds.size
		let oldContainerSize = CGSize(width: CGFloat(layout.width.value), height: CGFloat(layout.height.value))
		
		if newContainerSize.width != oldContainerSize.width || newContainerSize.height != oldContainerSize.width {
			layout.width = YGValue(newContainerSize.width)
			layout.height = YGValue(newContainerSize.height)
			layout.applyLayout(preservingOrigin: true)
		}
	}
I changed the container size and moved calling applyLayout to didLayoutSubviews. BUT this **results in a different layout** than before though.... I added this to the sample: override func viewDidLayoutSubviews() { let root = self.view! let layout = root.yoga let newContainerSize = self.view.bounds.size let oldContainerSize = CGSize(width: CGFloat(layout.width.value), height: CGFloat(layout.height.value)) if newContainerSize.width != oldContainerSize.width || newContainerSize.height != oldContainerSize.width { layout.width = YGValue(newContainerSize.width) layout.height = YGValue(newContainerSize.height) layout.applyLayout(preservingOrigin: true) } }
faimin commented 2017-07-10 03:26:40 -07:00 (Migrated from github.com)

+1 , I have the same question

+1 , I have the same question
NickGerleman commented 2023-06-13 08:04:16 -07:00 (Migrated from github.com)

We are deprecating YogaKit as part of the Yoga 2.0 release. We are still going to release a new revision based on the current state of the repo, but won't be accepting new contributions, since we are going to be removing it from the repo after.

We are deprecating YogaKit as part of the Yoga 2.0 release. We are still going to release a new revision based on the current state of the repo, but won't be accepting new contributions, since we are going to be removing it from the repo after.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#557
No description provided.