Is there a possiblity to obtain value od given Storyboard's duration when it is set to automatic? I need this exact value.
Or maybe there is a possibility to get notifcation when storyboard animation is starting?
Related
NSViewController's view size is not the same as the window's, I print the size in the viewDidLoad method and get (480.0, 270.0)
I'm not very familiar with appkit and I find that no matter how I resize the window and then re-run it, it prints (480.0, 270.0) every time, but the window size stays the same length and width as last time. I noticed that these two values were set in the storyboard, but I needed real values to calculate the layout of the text, and I tried window's proxy method, but that was too late. By that time the view had already been rendered and calculated
After various attempts it didn't work
I am using Cocoa and I have a NSViewController with the dimensions set. However, I want to programmatically change the dimensions based on an if/else statement. Basically "if this condition is met - the NSViewController becomes this size." Is there a way to change the dimensions of the NSViewController Frame or a way to do it with the initial Window Controller? I couldn't find anyone with the current correct syntax to do something like this.
I want to to assign a float value to a UIButtons frame in Storyboard.
But I can only use int values. Is it discouraged to use .5 for example? because I have some buttons and I want to place them according to the original photoshop design.
for example I have a button I need to be placed at X:151 , how can I achieve that?
Do NOT use a float value. As you have rightly observed, Interface Builder prevents this; but you should not do it even in code. Just the opposite: when you assign a frame (or related component) in code, you should set it to an integral value first. (In fact, there are even functions such as CGRectIntegral to help you.)
The reason is that otherwise you can end up between pixels on the screen, and the view will not display correctly (because there is no such thing as half a pixel). Stick to whole numbers of points so that you are using whole numbers of pixels.
Do it programmatically (click here for example), I don't know the reason why storyboard prevents from using non-integer values for frame ingredients, however I do know three things:
It works programmatically. (just assign a dummy value in storyboard and overwrite it in code later on.)
Apple uses non-integer values for their native objects in iOS, for example the line separator between cells in table view is 0.5 point height.
Points are not pixels (response to the accepted answer, according to the time of writing these lines.)
First of all I was not able to find a solid reference of Not using float value on storyboard. So following a workflow/procedure to achieve float value on storyboard. Last tried with Xcode Version 7.3.1 (7D1014).
Select the view. Remove any previous constraint for the UIView if any. Then add all the constraints including the floating value. On my case it was Leading, Trailing, bottom and Height. Only Bottom have a Int value others are float. Press the "Add X Constraints" button.
Finally I have the following:
The problem is that whenever I want to edit the value, I have to remove all the previous constraints and add them again according to the new constraints.
Some time ago I saw this on one of the iTunes U movies (I think it was stanford).
I can't find the exact video unfortunately... So if you know please tell me.
I want to create a view where the user can use the slider to change the smiley face.
So my current plan is to subclass UIView, then use drawInRect to make the drawing.
But how do I hook the slider value to my drawing and how do I update it 'smoothly'?
In your value changed handler for the slider, ask the view to redraw itself. The view should clear its context first, then do whatever it needs to do given the inputs you'll pass to it (the value of the slider) before asking it to redraw itself using -setNeedsDisplay et al.
I'm using MonoTouch. When I rotate to LandscapeRight/Left I want to change the location of some of my buttons but I'm not having any success. I'm replacing the button.Bounds with a new rectangleF and setting that value in the WillRotate, but that's not working.
I am returning true in my ShouldAutorotateToInterfaceOrientation handler.
In principal what I'm trying to do is allow as much as possible to automatically rotate but then fix a couple of buttons that end up in a bad place.
WillRotate is called before rotation, you're going to want to modify the bounds in DidRotate instead.
Are you sure you want to change Bounds and not Frame? Bounds will change the buttons' dimensions, where with the Frame property you can adjust X and Y. Other than that: Geoff said it already: you'll need DidRotate
René