Zoom functionality on a UITableView - iphone

I have a UITableView in one of my views which is a bit small and I can't increase its height (as its size is fixed and there are other controllers too). Can I provide the zoom in/zoom out functionality in it (same as we get on map view) ? If yes, how ?
During my search I came to know that it is possible with scroll view but I don't know how. I added a scroll view to my view and on the scroll view I added my tableview but the zoom in/zoom out functionality does not work there. Please help me out
This is for iPhone iOS 4.1.
Thanks in advance

The UITableView will be consuming all the touch events in the table view. What you need to do to get around this is to intercept the touch events, identify zoom gestures, and then pass any events that aren't zoom gestures to the table view.
You can subclass UIWindow to add the touch interceptors. Look at the sendEvent method.

Related

How to auto arrange all sub views?

I have a UITextView at the top of a UIView, below many UIControls are there like buttons, table view... Possibilities are user can give multiple lines in UITextView, in that case I have to expand(increase height) for UITextview to show two lines, If UITextview height increase every other controls should go down accordingly, How to do it in iOS ? I heard android they are auto arranging easily, Is there any way to do like this in iOS?
Where should I concentrate? Any ideas will be helpful. Thanx.
You should use autolayout for achieving this.
raywenderlich autolaout
developer.apple.com
Auto Layout video tutorial
About Cocoa Auto Layout
This tutorial helps you to understand autolayout in a better way.
You could look at auto layout, it's available from ios6 onwards. It will allow you to easily (some even non programmatically) specify constraints to be maintained while the view hierarchy is being displayed. For a good tutorial see this.
If you are working on iOS5 or below I would recommend the following :
I am assuming that all your views are direct children of the textView, even if that isn't the case the grandchildren views (and further ancestors) will move automatically once their parent moves down.
for (UIView* view in yourTextView.subviews)
view.transform = CGAffineTransformMakeTranslation(0,Y_DELTA_VALUE);
//Y_DELTA_VALUE is the amount you want to move the subviews down by, the
//(amount of height the textView increases by)/2

Recreate UIPickerView with just one row showing

I need a "PickerView", that behaves like a normal UIPickerView, but only shows one row of data and has a custom design.
Something like you see in the image, showing the transition from subview 1 to subview 2. After the user lifts his finger and after the scrolling stops, only one subview will be shown:
IMAGE
So basically a scrollview which:
is endless in both, positive and negative directions by showing the same entries over and over
uses paging across several subviews
only shows one subview when not scrolling, and no more than two subviews when scrolling.
I can get a endless scrollview to work, but not with paging enabled. Paging will always limit my scrolling to the next subview.
So I'm thinking about creating my own UIView subclass which custom scrolling behaviour to mimic a UIPickerView. But before doing so, I wanted to get some opinions about the idea in general. Is creating a custom UIView the right way to go? Anyone has some experience with the expected performace? (There will be timers to handle the scrolling algorithm, which has to be recreated of course... :)
Another approach would be to subclass UIScrolView and implement the paging myself. I know when the scrollView starts decelerating
, so maybe there is a way to overwrite the contentOffset to have it scroll into the right position...?!
Any help is appreciated! Thanks!
Here is a great custom component, which seems to be able to do everything you need:
http://dev.doukasd.com/2011/04/infinite-scrolling-dial-control-for-ios/
It's not endless, but rather a modified UITableView with a huge number of cells.
Would it be feasible to just use a UIPickerView, but clipped to the middle row? You could turn off showsSelectionIndicator to remove the overlay and have the delegate pass back custom row views.

In a table view can we give zoom in and zoom out effect?

I want to zoom the table view to see the contents of the cell???i want to know whether it is possible???any kind of suggesstion is highly appreciated
Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
From UIScrollView documentation
Edit,
May be you should implement something like and alertView when user taps on cell. Present an animated scroll view and there do the zooming.

I have a UI Scroll View with UIButtons on top. How do i make it scroll when they touch and drag the buttons?

I want something similar to how the iPhone homescreen works. I have my scrollview inside my main view, which scrolls to the right, but when you touch on the UIButtons, they become highlighted and dragging means they don't end up getting pressed but also the scrollview doesn't end up scrolling. It doesn't do this on the homescreen. How can i make it similar to this?
A touch-down-drag is a completely different event. Apple doesn't support this directly—you'd have to code it in—start tracking the touches using the gesture responders as soon as a touch-down-inside is detected, then scroll the same amount, and stop scrolling at a touch-up-outside (or inside). This would most likely fall under the category of unusual use of interface elements, and could very well get you rejected.
I think this is a better answer to the question:
UIScrollview with UIButtons - how to recreate springboard?

Draggable UIView

I have 4 UIViews inside of a main view controller view. All I need to be able to do is drag the views around the "screen". Is UIScrollView the best option for this, or is there a simpler way?
Apple's Touches sample application contains code that does just this, so you might want to check it out.
UIScrollView should be used for scrolling, not dragging. And the 4 scroll views won't work if they're overlapped so don't even think of using UIScrollView in your case.
A dedicate UIView subclass that overrides -touches*****:withEvent: is needed. See http://github.com/erica/iphone-3.0-cookbook-/tree/master/C08-Gestures/01-Direct%20Manipulation/ for example.