The app launches into landscape mode, and everything works just fine except for the slider, which I want to be vertical. I want the slider to automatically transform into vertical at the same time the app launches and goes into landscape mode.
My question is: Into which function do I put the transform code?
I can put the transform code under a button in the UIView, and when I tap it, it does the transformation just fine. But that's not the automatic functionality I'm looking for.
If I put the code into awakeFromNib in UIView, it does the transform, but the slider is invisible! If I slide my finger up and down where it should be, I see the values changing in the label it's connected to.
I tried putting the code into viewDidLoad in UIViewController (where the view transform is), but I can't figure out how to get it to talk to UIView.
I can put the transform code under a button in the UIView, and when I tap it, it does the transformation just fine. But that's not the automatic functionality I'm looking for.
This looks like a weird problem. Could you maybe post your code which makes the transformation work when you press a button? If it really does then my suggestion below must be wrong, but I cannot reproduce the behavior you describe.
Quote:
Originally Posted by ggrm
If I put the code into awakeFromNib in UIView, it does the transform, but the slider is invisible! If I slide my finger up and down where it should be, I see the values changing in the label it's connected to.
This behavior is reproducable. The reason seems to be that the Layer moves beyond the bounds of the original frame. If I disable "Clip Subviews" in interface builder the slider stays visible. But it gets less responsive to touches.
Quote:
Originally Posted by ggrm
I tried putting the code into viewDidLoad in UIViewController (where the view transform is), but I can't figure out how to get it to talk to UIView.
This sounds more like a very basic question. What good is a view controller if you can't control the view? You need to set an IBOutlet and connect it to the slider in interface builder and go from there. But how could you transform the slider without such a connection?
The app launches into landscape mode, and everything works just fine except for the slider, which I want to be vertical. I want the slider to automatically transform into vertical at the same time the app launches and goes into landscape mode.
But apart from the peculiarities of your example. What you really have to do to solve your problem is creating the slider prgrammatically. This is an example init method for the view controller which first loads your nib file and then adds the slider. All you have to do is fit in the right coordinates.
I have a project to dim a light using a vertical bar. I was able to use the horizontal UISlider and rotate it. Everything work fine when I tested on the Simulator but I found out later that it didn't work well on the actual iPhone (after submitting to the app store and client complain).
I had to buy an iPhone to test it. There's a problem with slider, it works fine with horizontal bar, but when it rotates to vertical, the sensitive / easy to move the ball on the bar up and down is not good, very sticky.
Please help. I will pay for it if anyone have a solution to it. I need this asap. because my client is not happy.