Re: Updated View Bounds After Orientation Change...

2015-10-28 Thread Peters, Brandon
David and Ken,

Thanks. What I needed was right @13:48 of the second video!!!

> On Oct 27, 2015, at 1:50 PM, David Duncan  wrote:
> 
> In general I would highly recommend spending some time with this years Auto 
> Layout talks from WWDC. One of the many gems is the discussion on how to read 
> these logs:
> 
> 
> 
> 
> 
>> On Oct 27, 2015, at 6:53 AM, Peters, Brandon  wrote:
>> 
>> Ken,
>> 
>> Thanks. I think I have the idea. I will have to try it when I get home.
>> 
>> --Brandon
>> 
>>> On Oct 26, 2015, at 23:40, Ken Thomases  wrote:
>>> 
>>> Read these lines over and over until you see it:
>>> 
 On Oct 26, 2015, at 9:49 PM, Peters, Brandon  wrote:
 
 (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't 
 understand, refer to the documentation for the UIView property 
 translatesAutoresizingMaskIntoConstraints)
 (
 ">>> UIActivityIndicatorView:0x14eb3760.midX == + 10>",
>>> 
>>> Regards,
>>> Ken
>>> 
> 
> --
> David Duncan
> 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Updated View Bounds After Orientation Change...

2015-10-27 Thread David Duncan
In general I would highly recommend spending some time with this years Auto 
Layout talks from WWDC. One of the many gems is the discussion on how to read 
these logs:





> On Oct 27, 2015, at 6:53 AM, Peters, Brandon  wrote:
> 
> Ken,
> 
> Thanks. I think I have the idea. I will have to try it when I get home.
> 
> --Brandon
> 
>> On Oct 26, 2015, at 23:40, Ken Thomases  wrote:
>> 
>> Read these lines over and over until you see it:
>> 
>>> On Oct 26, 2015, at 9:49 PM, Peters, Brandon  wrote:
>>> 
>>> (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't 
>>> understand, refer to the documentation for the UIView property 
>>> translatesAutoresizingMaskIntoConstraints)
>>> (
>>>  ">> UIActivityIndicatorView:0x14eb3760.midX == + 10>",
>> 
>> Regards,
>> Ken
>> 

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Updated View Bounds After Orientation Change...

2015-10-27 Thread Peters, Brandon
Ken,

Thanks. I think I have the idea. I will have to try it when I get home.

--Brandon

> On Oct 26, 2015, at 23:40, Ken Thomases  wrote:
> 
> Read these lines over and over until you see it:
> 
>> On Oct 26, 2015, at 9:49 PM, Peters, Brandon  wrote:
>> 
>> (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't 
>> understand, refer to the documentation for the UIView property 
>> translatesAutoresizingMaskIntoConstraints)
>> (
>>   "> UIActivityIndicatorView:0x14eb3760.midX == + 10>",
> 
> Regards,
> Ken
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Updated View Bounds After Orientation Change...

2015-10-26 Thread Peters, Brandon
David,

In IB, I have a vertical UIStackView with an image view and a text view 
(stacked in that order). I add the activity indicator programmatically:

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

// add activity indicator and start animation
if _useActivityIndicator == true {

// set constraints
_imageView.addSubview(_activityIndicator)


_activityIndicator.centerXAnchor.constraintEqualToAnchor(_imageView.centerXAnchor).active
 = true

_activityIndicator.centerYAnchor.constraintEqualToAnchor(_imageView.centerYAnchor).active
 = true

_activityIndicator.startAnimating()
}
}

I get this error:

2015-10-26 22:44:42.971 Historic Sites Navigator[247:13410] Unable to 
simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't 
want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't 
understand, refer to the documentation for the UIView property 
translatesAutoresizingMaskIntoConstraints)
(
"",
"",
"",
"",
"",
"",
"",
"",
""
)

Will attempt to recover by breaking constraint


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch 
this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed 
in  may also be helpful.

I do not understand how the error is occurring.


On Oct 26, 2015, at 2:02 PM, David Duncan 
> wrote:


On Oct 25, 2015, at 12:13 PM, Peters, Brandon 
> wrote:

David,

I tried your suggestion, but the program terminates. I get this in the console:

view did load...
2015-10-25 15:10:57.893 Historic Sites Navigator[766:538109] *** Terminating 
app due to uncaught exception 'NSGenericException', reason: 'Unable to activate 
constraint with items > and > because they have no common ancestor.  Does the 
constraint reference items in different view hierarchies?  That's illegal.’

You need to ensure they have a hierarchy relationship before activating the 
constraints – you probably didn’t add one as a subview of the other yet.

*** First throw call stack:
(0x2635c68b 0x37716e17 0x2635c5d1 0x271fa7cd 0xce7d8 0xceeb4 0x2a43821b 
0x2a43879f 0x2a755c47 0x2a86185d 0x2a7590b1 0x2a547cff 0x2a547b39 0x2a5476ad 
0x2a54724f 0x2a459535 0x2a45942f 0x29cf45a9 0x123ed73 0x1243815 0x2631f9ad 
0x2631dea7 0x26271249 0x26271035 0x2f354ad1 0x2a486899 0xc5a44 0x37e62873)
libc++abi.dylib: terminating with uncaught exception of type NSException

I will continue to work on it though. Thanks...

On Oct 25, 2015, at 1:11 PM, David Duncan 
> wrote:


On Oct 24, 2015, at 8:45 PM, Peters, Brandon  wrote:

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 ->

Why do all this at all? Just add 2 constraints that tie the center of the 
activity indicator to its superview and it will remain centered always.

[_activityIndicator.centerXAnchor 
constraintEqualToAnchor:_imageView.centerXAnchor].active = YES;
[_activityIndicator.centerYAnchor 
constraintEqualToAnchor:_imageView.centerYAnchor].active = YES;

(or equivalent if you need to support prior to iOS 9).


// 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))

  }

___


Re: Updated View Bounds After Orientation Change...

2015-10-26 Thread Ken Thomases
Read these lines over and over until you see it:

On Oct 26, 2015, at 9:49 PM, Peters, Brandon  wrote:
> 
> (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't 
> understand, refer to the documentation for the UIView property 
> translatesAutoresizingMaskIntoConstraints)
> (
>" UIActivityIndicatorView:0x14eb3760.midX == + 10>",

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Updated View Bounds After Orientation Change...

2015-10-25 Thread David Duncan

> On Oct 24, 2015, at 8:45 PM, Peters, Brandon  wrote:
> 
> 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 ->

Why do all this at all? Just add 2 constraints that tie the center of the 
activity indicator to its superview and it will remain centered always.

[_activityIndicator.centerXAnchor 
constraintEqualToAnchor:_imageView.centerXAnchor].active = YES;
[_activityIndicator.centerYAnchor 
constraintEqualToAnchor:_imageView.centerYAnchor].active = YES;

(or equivalent if you need to support prior to iOS 9).

> 
> // 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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com