Ali Awais
Ali Awais

Reputation: 113

time between touch in and touch up

i have application view with nine icons on each page, i want to call a function when a certain icon is pressed for certain amount of time. similarly i want to do this with a cell in UITableView.

Upvotes: 0

Views: 148

Answers (3)

The button is easier because of the TouchUpInside and TouchDown events you can react to.

For a cell, you'd probably have to start a timer in setHighlighted:, and disable the timer when setHighlighted was called to unhighlight.

Upvotes: 0

Ali Awais
Ali Awais

Reputation: 113

For the icons view have used the TouchDown and TouchUpInside event to acomplish,

Used timeBetweenTouchRelease = [[NSDate date] timeIntervalSince1970]; when TouchDown

and Used the following timeBetweenTouchRelease = [[NSDate date] timeIntervalSince1970] - timeBetweenTouchRelease;

when TouchUpInside.

Still having problem with tablecell, i guess when using touch begin and end user may move his finger so that means user may have moved from one cell to another.

Upvotes: 0

Morion
Morion

Reputation: 10860

You can enable NSTimer on touchesBegan:withEvent and disable it on touchesEnded:withEvent.

Upvotes: 1

Related Questions