toggle quoted messageShow quoted text
I did the resizing in the viewDidEndLiveResize method and it does resize correctly, but the problem is that the image stays at the old size until the User stops re-sizing the window (e.g. mouseUp’s) and then it resizes them, which won’t do!
On 28 Sep 2018, at 19:15, Dave <dave@...
Hi Again,After digging around a little I find this:https://lists.apple.com/archives/cocoa-dev///2005/Oct/msg00476.htmlIt seems that someone else has noticed this way back in 2005! From looking at the article, it mentions:-(void) viewDidEndLiveResizeWhile I added to the GameImageView class and it does get called, I’m not sure if I can use it or not, but I’d really, really, really like to know if resizeWithOldSuperviewSize is a known bug or if I’m doing something wrong?All the BestDave
On 28 Sep 2018, at 12:34, Dave <dave@...> wrote:
This is a Mac Project.
I’ve not found anything obvious on this, so I’m trying to get to the bottom of why the auto-resizing mechanism is not working with Class that inherits from NSImageView called GameImageView. An object is created and added to the view hierarchy at run time.
The view hierarchy is actually setup in a Storyboard/NIB and looks something like this:
I am adding GameImageView to each of the GameCellView's at runtime. All the Views are now using resizeWithOldSuperviewSize to resize themselves and it works wonderfully EXCEPT then this mechanism is not working on the run-time added GameImageView’s, e.g. GameImageView ::resizeWithOldSuperviewSize never gets called, although it does get called in the GameCellView’s.
If I do this in the GameCellView:: resizeWithOldSuperviewSize method it works ok (e.g. the Image resized when I resize the window):
myCellStartPosition = [self getCellXYPosition];
myBoundingRect = self.superview.bounds;
myFrameRect = [self calculateFrameRectWithSuperViewRect:myBoundingRect];
myFrameRect.origin.x = (int) (3 + (myCellStartPosition.x * (myFrameRect.size.width + 2)));
myFrameRect.origin.y = (int) (3 + (myCellStartPosition.y * (myFrameRect.size.height + 2)));
self.frame = myFrameRect;
//** Setup the Image View Frame based on the Cell’s view *********************
myImageFrameRect = NSInsetRect(self.bounds,2,2);
self.pCellImageView.frame = myImageFrameRect;
e.g. if I set the the frame of the GameImageView in the Superclass it works ok. If I don’t do this expecting GameCellView:: resizeWithOldSuperviewSize to be called then the image does NOT resize, since it isn’t called!! I’m trying to understand why this doesn’t work as expected, I’m not doing anything different (apart from adding it as a subview at runtime) from the other classes in the hierarchy and they all work wonderfully.
I’ve more or less got it working, but this last part is driving me nuts, so if anyone can shed some light on what could be going wrong I’m be really grateful.
Thanks in advance.
All the Best
On 27 Sep 2018, at 20:10, Dave <dave@...> wrote:
I’m using Manual Layout on a Mac project. The View Hierarchy is built in Interface Builder and during run time I add a subview to one of the views. However, resizeWithOldSuperviewSize is not being called on these subviews. The subview in question is a subclass of NSImageView.
I’ve explicitly set autoresizesSubviews = YES in the view that adds the subview (actually is all the views in the Hierarchy).
Anyone have half an idea why resizeWithOldSuperviewSize is not being called? The frame of the parent rectangle is definitely being set…..
All the Best