@@ -188,36 +188,6 @@ static void InsertContentView(UIScrollView platformScrollView, IScrollView scrol
188
188
platformScrollView . AddSubview ( contentContainer ) ;
189
189
}
190
190
191
- static Size MeasureScrollViewContent ( double widthConstraint , double heightConstraint , Func < double , double , Size > internalMeasure , UIScrollView platformScrollView , IScrollView scrollView )
192
- {
193
- var presentedContent = scrollView . PresentedContent ;
194
- if ( presentedContent == null )
195
- {
196
- return Size . Zero ;
197
- }
198
-
199
- var scrollViewBounds = platformScrollView . Bounds ;
200
- var padding = scrollView . Padding ;
201
-
202
- if ( widthConstraint == 0 )
203
- {
204
- widthConstraint = scrollViewBounds . Width ;
205
- }
206
-
207
- if ( heightConstraint == 0 )
208
- {
209
- heightConstraint = scrollViewBounds . Height ;
210
- }
211
-
212
- // Account for the ScrollView Padding before measuring the content
213
- widthConstraint = AccountForPadding ( widthConstraint , padding . HorizontalThickness ) ;
214
- heightConstraint = AccountForPadding ( heightConstraint , padding . VerticalThickness ) ;
215
-
216
- var result = internalMeasure . Invoke ( widthConstraint , heightConstraint ) ;
217
-
218
- return result . AdjustForFill ( new Rect ( 0 , 0 , widthConstraint , heightConstraint ) , presentedContent ) ;
219
- }
220
-
221
191
public override Size GetDesiredSize ( double widthConstraint , double heightConstraint )
222
192
{
223
193
var virtualView = VirtualView ;
@@ -338,6 +308,16 @@ Size ICrossPlatformLayout.CrossPlatformArrange(Rect bounds)
338
308
{
339
309
var scrollView = VirtualView ;
340
310
var platformScrollView = PlatformView ;
311
+
312
+ var contentSize = scrollView . CrossPlatformArrange ( bounds ) ;
313
+
314
+ // The UIScrollView's bounds are available, so we can use them to make sure the ContentSize makes sense
315
+ // for the ScrollView orientation
316
+ var viewportBounds = platformScrollView . Bounds ;
317
+ var viewportHeight = viewportBounds . Height ;
318
+ var viewportWidth = viewportBounds . Width ;
319
+ SetContentSizeForOrientation ( platformScrollView , viewportWidth , viewportHeight , scrollView . Orientation , contentSize ) ;
320
+
341
321
var container = GetContentView ( platformScrollView ) ;
342
322
343
323
if ( container ? . Superview is UIScrollView uiScrollView )
@@ -347,23 +327,15 @@ Size ICrossPlatformLayout.CrossPlatformArrange(Rect bounds)
347
327
// container. (Everything will look correct if they do, but hit testing won't work properly.)
348
328
349
329
var scrollViewBounds = uiScrollView . Bounds ;
350
- var containerBounds = container . Bounds ;
330
+ var containerBounds = contentSize ;
351
331
352
332
container . Bounds = new CGRect ( 0 , 0 ,
353
333
Math . Max ( containerBounds . Width , scrollViewBounds . Width ) ,
354
334
Math . Max ( containerBounds . Height , scrollViewBounds . Height ) ) ;
335
+
355
336
container . Center = new CGPoint ( container . Bounds . GetMidX ( ) , container . Bounds . GetMidY ( ) ) ;
356
337
}
357
338
358
- var contentSize = scrollView . CrossPlatformArrange ( bounds ) ;
359
-
360
- // The UIScrollView's bounds are available, so we can use them to make sure the ContentSize makes sense
361
- // for the ScrollView orientation
362
- var viewportBounds = platformScrollView . Bounds ;
363
- var viewportHeight = viewportBounds . Height ;
364
- var viewportWidth = viewportBounds . Width ;
365
- SetContentSizeForOrientation ( platformScrollView , viewportWidth , viewportHeight , scrollView . Orientation , contentSize ) ;
366
-
367
339
return contentSize ;
368
340
}
369
341
0 commit comments