iPhone: Slide photos by finger - iphone

I want to implement something like Iphone Photo Gallery... How to slide images by finger, and how to do that animation if I want to slide photos by clicking on button ? Thanks...

Have a look at Three20 project, it has a lot of this gallery stuff already implemented and is open source. It has swiping through images implemented. If you want to do it by yourself, UISwipeGestureRecognizer would be a good starting point. Have a look at the sample code associated with it.

You need to use a PanGestureRecogniser on the view you want to slide.
UIPanGestureRecognizer *imgpan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:#selector(scrollBarDrag:)];
[imgpan setMaximumNumberOfTouches:1];
[self.svContainer addGestureRecognizer:imgpan];
[imgpan release];
Define this & as the pan is happening, slide in the next image...Hope i was clear.

Related

How to Resize iOS UI component same as Interface Builder

I'm working on a iOS app where in a screen, user can have multiple UI component. Also, user can drag and reposition those component.
Now, I want all UI component to be resized by user through finger touch(same as we can resize in Interface Builder with mouse).
EDIT:
As above screen shot of IB, we can hold any tiny squares around button with mouse and resize the button.Same thing I need to implement in my App by finger gesture (probably by UIPanGestureRecognizer).
I recommend you that you add a pinch gesture in those view to user can make zoom.
UIPinchGestureRecognizer *twoFingerPinch =
[[[UIPinchGestureRecognizer alloc] initWithTarget:self action:#selector(scaleObject:)] autorelease];
[[self view] addGestureRecognizer:zoomGesture];
and the method:
- (void)scaleObject:(UIPinchGestureRecognizer *)recognizer
{
NSLog(#"Object scale: %f", recognizer.scale);
}
and change the object size with that scale. Moreover you can use other gestures like:
UITapGestureRecognizer
UIPinchGestureRecognizer
UIRotationGestureRecognizer
UISwipeGestureRecognizer
UIPanGestureRecognizer
UILongPressGestureRecognizer
If you reject solution with pinch recognizer. I would suggest creating custom wrapper for UI components, that would create little squares in corners of the frame and in the middle of every side. Every square should have UIPanGestureRecognizer to control size of the object.
Guys thanks to this Beautiful Example, I'm able to achieve what I wanted to.
Now I am able to put editing handles & resize any UI component easily.
After searching about a week I got this solution, so thought of sharing.

Make UITextView react to tap event. (iphone)

I'm trying to implemet a scrollable Text view (not editable) that display some help information etc. and when the user is done with it all he has to do is tap it and it will disapear/hidden and the user will be back in the main screen.
The UITextview not reacting to tap event (or i'm not sure how to make it react to the tap event).
Any idea how to implement this ?
I also tried to put it inside a transparent button so i can capture the tap but then i cannot scroll the text view as it seem to be behinde the button.
i'm new to iphone , any help... gr8
Thanks
How about adding a tap gesture recognizer to the text view?
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(textViewTapped:)];
[yourTextView addGestureRecognizer:gestureRecognizer];

UIView is not receiving the touch event

I'm beginner in Ipad development, so I'm trying to do an application that will have some of the twitter application features.
The issue is that I have a UIViewController which has the content. When you click on a image it should show a view that has a video in it, all above each others (as in twitter APP), the issue is that the view is appearing and it shows the subviews in it, but it dose not receive any touch event and doesn't get the background color.
So can you help me?
thanks :P
Make sure that the userInteraction is enabled for the image view. You can do it from the Interface builder, or alternatively, do -
myImageView.userInteractionEnabled = YES
You can then add gesture recognizer to that imageView- in your case a tap gesture recognizer. That should work. To add a gesture recognizer:
UITapGestureRecognizer *tapGestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleTap:)];
[myImageView addGestureRecognizer:tapGestureRec];
Then handle the tap in the handleTap: method.

Drag UIView without disabling its child controls iPhone/iPad

I have a UIView control (white rectangle in image)
Moreover I am able to drag that control...
And when I press the button I load a subview which is another nib that I created and I placed random controls in it to illustrate my point...
If you guys are interested in finding out how I placed that nib file in that UIView control take a look at this question. I don't thing you have to read it in order to understand my question.
Anyways the problem when loading that nib file is that I can no longer drag the top UIView. Because of this I changed:
for:
in the UIView of the subview. In otherwords the UIView of the nib file that I am placing in the UIView that has the white background.
and when I did that I was able to drag the control but the controls inside the subview no longer works. I have also tried placing the touchesMoved method in the subview instead but when I do that the application behaves strange. Plus the purpose of placing the nib file in a UIView control was to avoid repeating the same drag funcionality on several nib files.
I actually need to create an application like a power point presentation and I need to change the slide as the user slides the UIView and if it's cords are less than x for example then I load the next slide (nib file) in that uiview controller. Maybe there is a simpler way of doing what I need but if I get this drag to work I am done cause I would just have to do that functionality just once.
You should leave the UserInteractionEnabled flag on for your subview if you want it to respond to events.
One way to achieve this would be to do your dragging using a UIGestureRecognizer.
UIPanGestureRecognizer is perfect for this (UIGestureRecognizer at apple)
Basically you'd attach the gesturerecognizer to the view which you want to pan then adjust it's position in the callbacks it provides.
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:#selector(handlePanGesture:)];
panGesture.minimumNumberOfTouches = 1;
[draggableSubview addGestureRecognizer:panGesture];
[panGesture release];
Then in the handlePanGesture method you figure out how far the user panned using the translationInView method of the recognizer which it gets passed and translate the subview accordingly.

Is there a way that I can make an overlay view on the iPhone SDK?

I've seen examples of overlay views in different iPhone apps (Skype, Phone.app (while making a call), Google Mobile) and I was wondering how I could do the same in an app.
I'm making an app which has a record button in it and when that button is pressed, I want a nice looking overlay (similar to the overlay view that appears when making a call on the iPhone) that says "Recording" with a count in seconds to appear along with a stop button.
Is there any guide or anything I can look at to help me do this? Thanks.
Also I was wondering how I can make a vertically long view that requires the user to scroll with their finger that isn't a TableView. Also thanks.
I usually just create them myself; it's just a UIView which you insert above your other subviews.
UIView *overlayView = [[UIView alloc] initWithFrame:self.view.frame];
overlayView.backgroundColor = [UIColor blackColor];
overlayView.alpha = 0.4;
[self.view addSubview:overlayView];
[overlayView release];
As for your second question check out UIScrollView's.
For scrolling you need a UIScrollView. Look at the class reference for examples on how to use it.
For my overlays I push a new modal view which I make transparent.