iphone - Shrink image on scroll away in UIScrollView - iphone

So I have a UIScrollView in my app's menu. I have paging enabled and each page contains a button and an image. I would like to add a little animation where these start to shrink as they disappear off the screen (when the user scrolls to the next page).
I know I could do this by creating a property for each button and image and then manually changing the frame size in the scrollViewDidScroll method.
Does anyone have a more elegant solution so that I dont have to hard code each one in? It is possible that there's a predefined attribute for this or something?

Is each "page" in the scrollview actually a view or view controller? Whatever it is, hopefully it's an instance of some class, and thus reusable. Add a method to the custom view/view controller that uses the UIView animateWithDuration: methods to make the button and image shrink. Call that method when you determine that the scroll view has moved enough.

Related

Adding a UIToolBar above a UITabBar - Logic Issue

I need to know the logic of how to write this code.
This is my problem.
When a user taps a button, I need to show a UIToolBar (with a few buttons on it) on the view. This toolBar should appear ONLY above the UITabBarcontroller.
The view is a UIScrollView, so if I hardcode the position of the UIToolBar, it will be displayed in the wrong position each time the user scrolls (Hope you understand what I am saying).
I did the following. I hard coded the position of the UIToolBar (so it will place above the tab bar), and added it to the Window. This sounds like a good solution as the windows size will not change at all instance.
But, I don't want to add this to a Window. So is there any other way I could solve this problem?
I would add an additional UIView to the window so that it acts as a container for both the UIScrollView and UIToolbar. Then resize the scrollview so that it falls short of the toolbar.
You should be thinking of this as layers of views

floating button above UIScrollView in Storyboard

Is there an easy way of putting a 'floating' button above a UIScrollView in Storyboard? I would like to add a lock button to toggle scrolling on and off. I guess I could do this in code but it would be nice if it could also be done via XCode.
Just drag the button onto the view somewhere over your UIScrollView. Now, IB will automatically dump it in the scroll view, but you can move it out by using the object browser.
Open the object browser
Drag the button out to the same level as the UIScrollView
Ensure that the button is below the scroll view in the list (this means it's above the object in the view hierarchy)
You may have to use the inspector to set the button's actual location rather than dragging it around. Dragging it around for placement will most likely cause it to jump back into the scroll view.

Display 2 images at the same time in UIScrollView

I'm quite new to iPhone development, and now dealing with a remote control app. Currently I can receive desktop image and perform simple mouse operations. But I still want to show a mouse pointer on my iPhone screen.
The desktop (very big, 1280X800) is in a image view which is the subview of a scroll view. Is there any way I can add a pointer image on top of the desktop image, and set it to any place I want? The pointer image do not receive any user interaction, it would be just floating on the desktop image.
Thank you very much for help.
Yes, just create a new UIImageView (or any other UIView subclass) with a frame based on where you want it to appear and add it to the scroll view's view using the addSubview: method. By default subviews you add later will appear above subviews you add earlier, but you can explicitly control which view appears on 'top' using 'bringSubviewToFront:'.

iPhone: How can I turn a flipside view into a scrolling UIScroll view?

This should be simple.
I'm making a very basic app, based on the Utility Application template of XCode.
On the flipside, I have more content than fits the screen.
The flipside is a UIView. I think it should be a UIScrollView, but somehow I don't get it to work.
Can anybody here advise me on this?
With a UIScrollView it is not enough just to place the control into Interface Builder and place the items within it; you have to set its content size in code.
Therefore in the -viewWillAppear method (or similar) you should have something like:
[scrollView setContentSize:CGSizeMake(320, 600];
This would make the content size inside the scroll view 600 pixels high (ie larger than the height of your iPhone display). If everything else is wired up correctly, this shoud now work.
Note: You may also then need to reposition your objects within the view. Set frame.origin for the objects that require this...

Does UIScrollView have a special content view for making the scrolling possible?

I wonder if UIScrollView has got an "hidden" subview acting as an container for the content. If I scroll a scroll view, is that content view moved up/down in the scroll view? Or is the scrolling offset applied to the bounds of that UIScrollView instance?
Or: Does UIScrollView use an additional view as container, or is all content added directly to the view? The documentation doesn't tell much about wether it has a content container or not.
UIScrollView doesn't have a content container but it is standard practice to create one yourself and add all your subviews to it. It's not necessary, though, at least as long as you use the scroll view just for scrolling. If you need the zooming functionality, too, having one content view often simplifies things because the delegate method viewForZoomingInScrollView: requires you to return a single view.