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é
Related
I have a Image View on my storyboard, and when I am trying to use it as a background. No matter what I do, it always stays on top. How would I change it so that it would be a background image, I don't care weather I do it programmatically through swift or through another way.
In the Xcode Interface Builder, you can adjust which views are in the front by selecting the view and going to Editor -> Arrange -> Send to Front, Back, etc.
This can also be done programmatically using UIView methods like bringSubviewToFront:
By moving any of item up/down you can set their layer state. The first one will be on back then second will appear on the first one then.... last one will appear on top most.
I hope this will help you.
If you decide to do it programmatically, you can modify the zPosition property of the view:
myImageView.layer.zPosition = 1
Higher numbers are closer to your face, lower numbers are closer to the screen. So to set your image view as a background, make sure the other views have higher z-positions than it.
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.
I want to know exactly where I am placing my images programatically, and therefore need to know the coordinates of my storyboard.
Is there a way to view these from the interface builder in Xcode?
Your workspace dimension is 320X460 suppose you want to add a button programmatically first go into IB and place a button where you want it to be and then in the right side check the coordinates of button in show the size inspector and use those coordinates in your code this will give you a fair idea about where your button will go after you add it programmatically... hope this will help you
NO. Use your imagination. Programmatically added visual objects cannot be seen in IB.
Instead, you could place an object in IB, adjust it's position to the desired one, read it's frame, delete it from IB, and use it's frame values to programmatically add id.
XCode Attributes
Why are the Xcode 4 attributes for setting the frame disabled?
I see many posts on this and I did set the view controller simulated metrics to various settings. However, you can see in the image that the X value is 320 and the Y value is 250!
This would place the view controller way off center. This view controller is in a storyboard so does that make a difference? If I see to "free form" for simulated metrics I can change the width and height but the X and Y values are stubborn.
Why are the X and Y values weird and NOT changeable?
I was about to delete this question but answering it so that other poor souls can know the reason for this.
I completely missed the "Origin" setting in the attributes area. It's the box to the left of the coorindate values. For some reason it changed and I didn't notice.
I set it back to the upper-left so that the coordinates can be interpreted correctly.
Hey guys, I've just migrated my image selector from NSCollectionView to IKImageBrowserView. I've got almost everything set up the way I want it, except for the selection ring. I don't like the greyed out background that IKImageBrowserView defaults to, and I wanted to do a yellow stroke around the edge of my selected image to indicate it's selection (like in iPhoto). Is is possible to override the draw state of IKImageBrowserCell? I haven't been able to find any way to do it yet. It doesn't have the simple drawRect methods that I'm used to. Any help would be appreciated. I'm assuming I have to use CALayers?
I overrode - (CALayer *)layerForType:(NSString *)type and tried just as a test, setting the layer corner radius to 0, but it didn't seem to change anything. The method is being called because if I throw a breakpoint in it, it stops there. However, even if I return nil from that method, it still draws the images like usual.
Thanks!
That is the right method for customizing the IKImageBrowserCell.
Using CALayers and configuring different attributes, you can control many facets of how the images are presented.,
A layer of type = IKImageBrowserCellSelectionLayer is what you will want to change to have the display behave and present as you wish.
Here's a link to Apple's sample code project that will get you started