• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Updated View Bounds After Orientation Change...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Updated View Bounds After Orientation Change...


  • Subject: Updated View Bounds After Orientation Change...
  • From: "Peters, Brandon" <email@hidden>
  • Date: Sun, 25 Oct 2015 03:45:08 +0000
  • Thread-topic: Updated View Bounds After Orientation Change...

Devs,

I have a UIStackView, which holds an image view and a text view. The image view has an activity indicator view as a subview (I add this programmatically). When the view initially view loads, I center the activity indicator view within the image view and starting the animation for the AIV. But, in the process of waiting for the image to load, if I rotate the image view, the AIV needs to be re-centered. I added code to listen for the status bar orientation change notification, and have a method to invoke upon the notification (UIApplicationDidChangeStatusBarOrientationNotification). In that method, I attempt to get the bounds of the image view and use that to re-center the AIV within the image view. But, it seems that the value of the bounds of the image view is not changing when the device orientation changes. Is there a “reliable" way to get the updated bounds for a view after the device orientation has changed? Code ->

// start listening for orientation changes
            NSNotificationCenter.defaultCenter().addObserver(self, selector: "orientationDidChange:",
                name: UIApplicationDidChangeStatusBarOrientationNotification, object: nil)
…
  func orientationDidChange(notification: NSNotification) {

        // get image view bounds
        let viewBounds = _imageView.bounds

        // recenter the activity indicator
        _activityIndicator.center = CGPointMake(CGRectGetMidX(viewBounds), CGRectGetMidY(viewBounds))

    }

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Updated View Bounds After Orientation Change...
      • From: David Duncan <email@hidden>
  • Prev by Date: NSSplitView in a separate NSWindowControl doesn't show for some reason
  • Next by Date: Re: NSSplitView in a separate NSWindowControl doesn't show for some reason
  • Previous by thread: Re: NSSplitView in a separate NSWindowControl doesn't show for some reason
  • Next by thread: Re: Updated View Bounds After Orientation Change...
  • Index(es):
    • Date
    • Thread