Is Selecting Multiple Items with a Two-Finger Pan Gesture only possible with UITableViewController? - swift

I tried implementing the selecting multiple items with a two-finger pan gesture. However, the checkmarks didn't always appear and disappear when tapping edit to start the process, or tapping done when finished.
I later discovered that it works fine when using a UITableViewController after choosing the different controller from cocoa touch menu, instead of the UIViewController and UITableView I was using before.
So my question is: is it correct for me to now assume that these gestures when used in a table are really meant for a dedicated table view controller (with all the extra functionality you only get from it)?

Without any example code, I can't really see what might be going wrong. Have a look at the documentation to see if you are implementing it correctly.
https://developer.apple.com/documentation/uikit/uitableviewdelegate/selecting_multiple_items_with_a_two-finger_pan_gesture

Related

Swift Instagram's profile view with its exact behaviour

I have a problem where I have to create a view as similar as instagram's profile view. I have managed to get very close by digging into many solutions and I think I have found the best one for the purpose. I just need to get the final touch to resemble Instagram's profile view completely and I can't find the solution.
I leave the complete source code here so you can keep up with me: https://github.com/eduasinco/ProfileView
When you look at the project you will see a headerView on top of all other views, I have set the view of this header to be a PassthroughView which means that every action on that view will be ignored and pass to the next in the responder chain which in this case is one of the scroll views behind.
So far so good, nevertheless there is a small nuance, inside the header view there is a segmentControlView which is in charge of switching the pages, if you touch that segment control it will change pages just fine, the problem comes when you try to scroll the view from the segmentControlView it wont work. I would like to make this scroll behaviour happen as similar as Instagram's profile view.
To sum up, I would like to have a way to make segmentControlView work as it is doing now but also be able to scroll from it in the same way you can scroll when you are touching any other place inside the header view.
I have also tried all kinds of touch overriding but none of them works.
Any help will be appreciated

iPhone transition effect to reveal an updated version of the same view

So I have an app on the main page is details of the current date.
The page has left and right buttons to move to previous and next dates and a table of info below. This all works.
However I want to add a swipe between the days, now doing the swipe control is easy and I have done that.
However I want to give the visual indication of a swipe.
I am not changes views , I am simply refreshing the current view.
If you look at myfitnesspal (free app) , that swipes between dates in the same way I am after.
It scrolls off (a copy?) of the screen to one side , slides in the latest version to replace it.
I am at a loss on how to achieve such a simple effect without going for multiple views which unless I am misunderstanding would be over complex.
Use a UIPageControl, here is a tutorial of how to implement one using only two views: Cocoa with Love UIPageControl sample
Both views can be identical, (instances of the same Class, created programmatically or 2 CustomView outlets on IB)
This way you only need to update the view that's going to slide in the screen.

iPhone application - pop up dialogue - sort of

I have an iPhone application which is, in essence, a list. There is a UINavigationBar at the top, and then there is a UITableView which holds the list. I'd like to have an option in some way or another of allowing the user to sort the list in different ways. So, in my mind, I picture having a NavigationItem on the UINavigationBar that, when touched, a little pop up dialogue comes up. You select the "sort" you want, a check mark appears next to it, and the dialogue goes away.
I'm not really sure how to do this. I tried creating a UIView, adding a UIViewController onto it (which held this list of different "sort" parameters (ex. sort alphabetically, sort by date, etc) in a UITableView. But the UITableView isn't responding to any touches, and I'm not sure why.
Does anyone have an idea for using Apples wonderful interface for having an option like this? I can't use a UISegmentedControl below the UINavigationBar, because there are 5 possible options, and I can't fit all that in a single UISegmentedControl.
This sounds like a job for the UIPickerView. You could just slide one up from the bottom of the view whenever that button is pressed. I've done this in the past and it works well.
You won't get a checkmark, but if you want a pop-up I suggest using a UIAlertView.
Have you looked into UIActionSheet at all? https://developer.apple.com/documentation/uikit/uiactionsheet
It seems like it might be a good fit for this approach. The action sheet will be a bit tall since you will have 5-6 buttons in it, but it should get the job done and they are really easy to implement.
The way you are approaching it with displaying another view with its own UITableView in it would work also, but it doesn't seem like the best approach to me. Granted, if you are set on going with that approach, provide us with some code so we can try to figure out why the UITableView isn't responding to touches.

Drag & sweep with Cocoa on iPhone

I'm about to start a new iPhone app that requires a certain functionality but I'm not sure if it's doable. I'm willing to research but first I just wanted to know if I should at least consider it or not.
I haven't seen this in an app before (which is my main concern, even though I haven't seen too many apps since I don't own an iPhone), but an example would be the iPhone shortcuts panels: you can hold on an app, and then drag it to another panel, sweeping while still dragging it. But this is the core app, is it possible to reproduce something similar within a normal app?
I only need to be sure it can be done before I start digging, I don't need code examples or anything, but if you have some exact resources that you consider helpful, that would be appreciated.
Thanks!
Yes. If you have your custom UIView subclass instance inside a UIScrollView, your view controller just needs to set the UIScrollView to delay content touches and not allow it to cancel touch events.
[scrollView setCanCancelContentTouches:NO];
[scrollView setDelaysContentTouches:YES];
When the user taps and holds in the custom view, the event goes to that custom view, which can process the touch events to drag an item around, but if the user quickly swipes, it scrolls the view.
The "panel" view that you're referring to appears to be a UIPageControl view — although, perhaps, the specific incarnation of this view that Apple uses for the iPhone's home page may be customized.
Instances of generic UIView views that you might touch-and-drag will receive touch events. By overriding methods in the view, these events can be processed and passed to the page control, in order to tell it to "sweep" between pages.
If I wanted to do what you're asking about, that's how I might approach it. It seems doable to me, in any case.
Start with this: Swip from one view to the next view
Try using a UIButton that tracks the time since the state of the button changed to "highlighted". You may need to do this in order to track the dragging and move the button around:
Observing pinch multi-touch gestures in a UITableView
Check to see if the button starts overlapping one side of the screen while being dragged. If s certain amount of time elapses since the button first started overlapping the edge and then manipulate the UIScrollView so that it switches 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 down, etc.
In any case there's no reason why this couldn't work.
If UIButton doesn't work then perhaps try a custom subclass of UIControl (which tracks the same touch down actions etc.). If that doesn't work then use the window event intercept thing to track everything.

Nested UIScrollView-iPhone photos application

I have been facing the same nested UIScrollView problem for long time.I tried some open source codes like Scrolling madness ,three-20 and others but all fails finaly.I am trying to make a photo Viewer application same as iPhone.For that I have created the structure like this:-
1)one View controller.
2)on view of view controller one UIScrollView (i.e inner/parent scroll view) as a child.
3)on inner/parent scroll view number of child scroll views(i.e. outer/child scroll views) ,each represents one page of photos application.
4)On each scroll view one image View on which i am displaying my image.
So what I want is when user scrolls the outer scroll view it should scroll horizontally with all the child views so I will get the look and feel of paging in photos application.Also when user is on one specific image(i.e. child/outer scroll view) he should be able to zoom in/out,swipes and perform single/double tapping.I was able to make it work in sdk 2.1,but it dosnt work since sdk 3.0.Please tell me the idea behind your project.Means which scroll view you are subclassing ,in which view to detect touches.How this completely child - parent relation should be.
If possible provide any sample code also.
There is a WWDC session from 2010 that deals with this very issue.
Here's the short of it:
You need a single scroll view that is paginated and scrolls horizontally. Each "page" of that scroll view is another scroll view containing a photo.
First, it looks like you want to subclass UIScrollView? Every interaction method you need is provided for you in either the delegate callbacks or the touch methods. (Many of Apple's more advanced classes, such as UIScrollView, react poorly to subclassing.)
Second, it sounds like you have a first responder problem. IOW, your innermost scrollview isn't getting the first crack at the touch events.
Andrew
I also struggled with this for a long time trying samples you mentioned. I could finally figure it out with the samples provided by apple (iphone dev center).
http://developer.apple.com/iphone/library/samplecode/Scrolling/Introduction/Intro.html
http://developer.apple.com/iphone/library/samplecode/ScrollViewSuite/Introduction/Intro.html
The first one is pretty basic and probably what u already have. The second one is all about zooming, etc. Just study these and the samples you already have, I think you will be able to figure it out. On specific topics just come back here search for answers or post another question.
EDIT: I forgot this one check out these examples by Andrey Tarantsov hosted on github. This is what you want... http://github.com/andreyvit/ScrollingMadness