UIScrollView in "U" shaped - iphone

I want to know whether it is possible to create a scrollview that has a "U" shape or consisting of any other curvy patterns??
Any ideas??

You can write a Custom Gesture Recognizer to recognize a "U".
It involves implementing the following methods:
- (void)reset;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
and doing the geometry to find the pattern you are looking for.

For rendering, probably some kind of transform layer could help. For touch processing, however, you probably are on your own.

Related

touchesBegan is not triggered

I used the codes below to detect touch on the object
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *allTouches = [touches allObjects];
for (UITouch *touch in allTouches)
{
NSLog(#"TOUCH DETECT");
}
}
but it is not triggered
Welcome any comment
What kind of object? touchesBegan:withEvent: is only called for UIResponder subclasses.
Also, if it's a UIView, make sure userInteractionEnabled is YES.

touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event doesn't get called

i am making a cocos2d game and i can't get the touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event to be called. Is there something i should do besides including this function?
When using cocos2d with touches you should use the following methods instead
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

Custom "Swipeable" UIScrollView does not work properly on iPad - works fine on iPhone

I am working to make my iPhone app compatible for the iPad. The user can tap or swipe the screen to activate certain functions, and it works fine on my iPhone version. There is a UIScrollView on the page which I have subclassed to make it "swipeable," i.e. it passes up all of its touch functions to its superview as such:
#implementation SwipeableScrollView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self.superview touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
[self.superview touchesMoved:touches withEvent:event];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
[self.superview touchesEnded:touches withEvent:event];
}
#end
This works fine on the iPhone version, passing both taps and swipe gestures, but on the iPad, I get the following strange behavior:
Taps are passed to the superview properly.
But, swipe gestures are not passed at all.
Any idea why this would be working on the iPhone but not the iPad?
The problem is, that UIScrollView on the iPad cancels content touches very fast, even if canCancelContentTouches is set to NO. Also, overwriting -touchesShouldCancelInContentView: does not help. Read more here: link text
While overriding touch events was necessary on the iPhone, for the iPad Apple has introduced UIGestureRecognizers that make tasks like this much more straightforward and easy to implement. You will probably need to refactor your code to use them.
you can make custom uiscrollView and implements it's delegate so you can do what you want with scrollview it works with me fine
#import <UIKit/UIKit.h>
#protocol ScrollingDelegate <NSObject>
#required
- (void)scrolltouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)scrolltouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)scrolltouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
#end
Implementation
#interface CustomScrollView : UIScrollView
{
id <ScrollingDelegate> delegate;
}
#property (nonatomic,strong) id scrollDelegate;
#end
#import "CustomScrollView.h"
#implementation CustomScrollView
#synthesize scrollDelegate;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self=[super initWithCoder:aDecoder];
if (self)
{
}
return self;
}
-(BOOL)touchesShouldCancelInContentView:(UIView *)view
{
return NO;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.scrollDelegate scrolltouchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.scrollDelegate scrolltouchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.scrollDelegate scrolltouchesEnded:touches withEvent:event];
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
}
#end

iPhone UITableView row drag-move

How would you know if a row from UITableView has been move via drag? Is there an event to catch?
-(void) touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event

warning:'UIResponder' may not respond to '-manageTouches:'

this is my program .
//Interface file.
#import <Foundation/Foundation.h>
#interface reportView : UIView {
}
- (void)touchesBegan: (NSSet *)touches withEvent: (UIEvent *)event;
- (void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event;
- (void)touchesMoved: (NSSet *)touches withEvent: (UIEvent *)event;
#end
//ImplementationFile.
#import "reportView.h"
#implementation reportView
- (void) touchesBegan: (NSSet *)touches withEvent: (UIEvent *)event{
[self.nextResponder manageTouches:touches];
}
- (void) touchesEnded: (NSSet *)touches withEvent: (UIEvent *) event{
[self.nextResponder manageTouches:touches];
}
- (void) touchesMoved: (NSSet *)touches withEvent: (UIEvent *)event{
[self.nextResponder manageTouches:touches];
}
#end
I am getting the warning.
warning:'UIResponder' may not respond to '-manageTouches:'
I got 3 warnings as above.
I am getting the needed output correctly but how to resolve the warnings.
First, since your code looks exactly like listing 14.2 from iPhone in Action, did you remember to copy the code for -manageTouches: from listing 14.3 into your class?
Assuming that you did, the issue is that the nextResponder property points to an instance of UIResponder, which could be just about anything (your class, a window, some other OS-managed thing....), and the compiler doesn't know for sure that this particular responder implements a method -manageTouches:. Your options are basically to either live with the warning, or cast the value of nextResponder to your class. (FWIW, the bottom of page 247 mentions this.)
For that matter, you don't really know, at runtime, that the next responder will respond to that message. To be on the safe side, you might want to use -respondsToSelector: or -isKindOfClass: to validate that assumption.