I have a tableView and on a 3D touch its cells display the View Controller behind it along with a UIPreviewAction that will share a URL that the "peeked" View Controller fetches.
The problem is that the server doesn't always come back with the URL before the UIPreviewActions are initialised and I don't want to give the option to share if the URL doesn't exist (certain pages don't have a URL).
Is there any way to reload the UIPreviewActions after the View Controller has loaded?
Related
The app I am making has multiple pages which the user swipes between. I need the user to be able to press a button and that create a new page in the app, and then also for the user to be able to delete that page of the app. Is there a way to generate/delete a view controller while the app is in use? Or do I need the view controllers already to exist and somehow lock/unlock them when the user adds/deletes them?
You don't have to create all the view controllers already and somehow lock/unlock them when the user adds/deletes them.
You can use UIPageViewController for this purpose. Using UIPageViewController you will able add and delete view controllers.
Another way of implementing the same feature without the use view controllers as page is by using a UICollectionView with its cells as page and paging enabled. Here in this case the size of the collection view cell be same as the size of the screen.
To have a snapchat like multiple view controller you could probably use a UIPageViewController with your custom views or a scroll view with paging enabled.SwipeView also seems like a nice implementation. see this stack overflow post for some other options and some implementation methods.
How do you create a banner (say, above a UITableView or something) that will switch images after a given time, or upon swipe. It then recycles through after a set number of images. See the below provided example from the IF app).
Also, I'm not necessarily looking for code here, but simply general features of Xcode I'd use to make it happen (ie, UIImageView within a ContainerView with gesture recognizers or something). Any ideas?
Here's the first image:
Then the beginning of the transition:
Then the second image in place:
This is an example of how to get that exact behavior using UIPageViewController. From the documenation:
A page view controller lets the user navigate between pages of content, where each page is managed by its own view controller object. Navigation can be controlled programmatically by your app or directly by the user using gestures. When navigating from page to page, the page view controller uses the transition that you specify to animate the change.
In my new Swift app I am using a slide side menu with SWRevealViewcontroller.
On the rear view controller there are several fetch requests to retrieve the number of core data objects that meet some conditions. On the front view controller, the app user can create new core data objects.
In the normal way of using the app, the app user creates or modified the core data objects, and later he/she can reveal the rear view controller to see the number of objects of each type.
Please take a look of the two view controllers:
Front view controller:
If the user taps on the +button, a new object is created.
if the user taps on the menu button, the rear view controller is shown, as you may see in the image:
And now, finally my question: As you may see in the image, both view controllers are loaded and showed. I want to know if it is possible that on this scenario, with both view controllers on screen, if the +button is tapped on the right view controller, could I implement a way to perform the fetch requests on the left view controller to update the count of the objects of each type?
I have solved it using a NSTimer on the rear view controller. I guess this is not the best solution, but it works. If the user taps on the +button to create a new object, the timer launches the fetch request to update the number of objects from each type.
I've a popOver with some images and when I touch in one of then I'd like to get this image and show this image in viewController.
The app is basically the viewController with the button witch call the popOver with the images.
Any suggestion ?
sorry about the english.
I guess your popover is also a view controller and you must be having paths for all the images displayed in that view controller. Additionally you must be displaying those images either in a tableView or collectionView. So what you can do is just get the path of your image and then pass this image path back to your original viewcontroller. There in your main view controller you can get the image with the help of the path. One problem you might face is passing this image back to the main view controller for which you can search "passing data between viewcontrollers". There are real good answers to that question.
I have a universal application with a list of items (loaded from a backend) and item details (loaded from a backend as well). Each view controller listens to the UIApplicationDidBecomeActiveNotification, so that the view is refreshed when the user (re-)opens the app. That works so far.
Now my problem. On iPad, I have a split view. So, when the user (re-)opens the app in landscape, both views are reloaded. If there is no connection to the backend, the user gets two alerts with Retry/Cancel options, one above the other. That is not what I want... I have one default item which does not require connection to the backend and I want to set it to be selected and to display its details in the detail view. Always when the originally selected item is missing in the master view.
What I have done so far... In my master view controller, I check whether the selected item is available after the refresh and if not, I update the selection and the detail view. This should solve the problem when the requests from the left and from the right pane are processed in the correct order. However, currently both view controllers get the UIApplicationDidBecomeActiveNotification and make asynchronous requests to the backend.
Has someone experience in refreshing split views? What would be the right way to solve my problem? I really don't want to introduce additional notifications/complexity. I hope, there is some standard way to reload the data.
Well, I found a solution.
I create for each view controller a property alertView and store there the alert view that is displayed. In viewWillDisappear, I dismiss this alert view. So, when the details for my default item are displayed to the right, the alert view of the "old" controller is dismissed and I have only one alert view.
It is for sure not the perfect solution and I would be happy if someone can give me a better one. But for now, that works fine.