Drag and Drop with Cocoa on iPhone

I'm going to launch a new iPhone app that requires some functionality, but I'm not sure if this is possible. I'm ready to research, but at first I just wanted to know if I should at least consider this or not.

I haven’t seen this in the application before (this is my main concern, although I haven’t seen too many applications since I don’t have an iPhone), but the iPhone shortcut bar can be an example: you can hold the application and then drag it to another panel, sweeping while dragging and dropping. But this is the main application, is it possible to reproduce something like this in a regular application?

I just need to make sure that this can be done before I start digging, I do not need code examples or anything else, but if you have the exact resources that you find useful, this will be appreciated.

Thanks!

+1
source share
3 answers

Yes. If you have a custom instance of a UIView subclass inside a UIScrollView, your view controller just needs to configure the UIScrollView to delay the touch of content and not let it cancel touch events.

[scrollView setCanCancelContentTouches:NO]; [scrollView setDelaysContentTouches:YES]; 

When the user selects and holds in the user view, the event jumps to that user view that can handle touch events to drag the item around, but if the user quickly searches, it scrolls the view.

+1
source

The panel view you are talking about looks like a UIPageControl - although perhaps the specific embodiment of this view that Apple uses for the iPhone homepage can be customized.

Instances of common UIView views that you can tap and drag will receive touch events. By overriding the methods in the view, these events can be processed and passed to the page control to tell it to "sweep" between pages.

If I wanted to do what you are asking, how can I approach him. In any case, this is possible for me.

0
source

Start with this: Move from one view to the next.

Try using a UIButton that keeps track of when a button’s state has changed to “highlighted”. You may need to do this to track and drag the button around:

Watching multi-touch gestures in a UITableView

Make sure the button begins to overlap one side of the screen while dragging. If after a certain amount of time elapses, since the button first began to overlap the edge, and then manipulated the UIScrollView to switch to the next page on the corresponding side of the screen.

You may need to use NSTimer to keep track of how long the button is held, etc.

In any case, there is no reason why this could not work.

If UIButton does not work, perhaps try creating your own subclass of UIControl (which keeps track of the same actions when clicked, etc.). If this does not work, use the window event capture feature to track everything.

0
source

Source: https://habr.com/ru/post/1399784/


All Articles