Note that there are some explanatory texts on larger screens.

plurals
  1. POUIScrollView -zoomToRect:animated: and CGPoint conversion between views
    primarykey
    data
    text
    <p>I have got a <code>UIScrollView</code> <strong>A</strong> with a subview <strong>B</strong>, (which itself is a subview of the contentView <strong>D</strong> of <code>A</code> -- so <strong>B</strong> is <strong>NOT</strong> the contentView of the scrollview <code>A</code>) which has a subview, let's call it <strong>C</strong>. </p> <pre><code>+------------------------+ | A | | | | +-------------------+ | | |D (=contentView) | | | | +-----------+ | | | | | B | | | | | | +--+ | | | | | | |C | | | | | | | +--+ | | | | | +-----------+ | | | +-------------------+ | +------------------------+ </code></pre> <p>I would like the scrollView to zoom exactly so that C fills my iPhone's screen, or at least display it to me as large as possible. I cannot wrap my head around how the <code>zoomScale</code> of the scrollview before the zoom (let's assume I zoom in when the scrollview is already zoomed in and has a zoomScale of 2.45). So the first question is, does the zoomScale affect the rect that the UIScrollView zooms into?</p> <p>My second question regards CGPoint conversion. iOS has some built in functions to convert CGPoints/CGRects between views, but I simply can't produce anything productive from the given references.</p> <p>Here is what I intended to do: </p> <p>1) Convert <strong>C</strong>'s origin to <strong>A</strong>'s coordinate system:</p> <pre><code>CGPoint originConvertedToAsCoordinateSystem = [self convertPoint:C.frame.origin toView:A]; </code></pre> <p>2) Zoom to the rect with the given origin of <strong>C</strong>:</p> <pre><code>//shortened for the purpose of readability CGPoint p = originConvertedToAsCoordinateSystem; CGRect zoomRect = CGRectMake(p.x,p.y,C.frame.size.width,C.frame.size.height); [A zoomToRect:zoomRect animated:YES]; </code></pre> <p>I have neglected the value of <strong>A</strong>'s<code>zoomScale</code> in my given example as I do not really know whether to multiply or divide the value. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload