How do I make an uploaded image permanent on a view controller in Swift? - swift

I am writing code to allow a user to upload an image on a view controller. The image can be uploaded successfully, but once you navigate away from the view controller and then come back to it, the image they uploaded is gone. How would I make the image a global variable so that when the user returns to the view controller, the image is still present? I am using imagePickerController to select the image for upload. This is my code

Related

How can i display photo from the library?

I'm using UIImagePickerController with source type UIImagePickerControllerSourceTypePhotoLibrary, the idea is i want to display the photo picked to full screen before the delegate will be called like using a navigationController to push to another view?
You can try to change the behavior of delegate method. After you select the image from the camera roll, in the delegate method you can create a new view controller and shown it as modal. Then insert two button in this view controller:
the first, used for reject the image and open again the camera roll
the second, used for accept the image
For open again the camera roll, basically, you must call the open method again (i suppose this method is attached as target of a UIButton).

How to display transparent view to show the Upload successful message on current view and then go back to root view controller

In my current view controller i m uploading the content to server and i want to show the user that the upload was successful and then take him to the root view controller to perform another action.
Is there a way i can do it.
Thanks,
Check out MBProgressHUD

Switching images from an array in an iphone app

I was helped here a while ago about loading images from an array, but would like to know the exact details please.
Where does the code go if my app will be as simple as images that load from an array depending on whether the user chose the next or previous button? Does it go in the View Controller class?
What do I need if I literally just need one view which displays a full screen image and the image gets changed depending on the user choice, like I mentioned above?
Thanks in advance
Regards
The view controller is responsible for controlling the view (receiving events from it, doing something then passing back data to it).
That said you can store your array in the view controller or in some other model class. Either way the view controller will be responsible for taking an image from this array and giving it to the view when it receives user input.
You just need to place a UIImageView in your view controller's view. Then assuming you're using IB you create an IBOutlet property in your controller to have a handle on this image view.
Then you need to get events from your user (either a button, or some other touch) and assign it to an IBAction that your controller can handle. When you handle the action you can remove the old image and assign a new image from your array to your UIImageView.
That's about as detailed as I can go given your current question. If you need more information please give more detail.

UIwebview delays loading

I have Login screen and second view which will be shown after login. On second view I have UIWebview which loads the url.
After login first it shows the empty view and slowly it loads the url. I want to show login screen with wait cursor, until the uiwebview loads the url and then want show that screen.
Can any body please provide code or sample for this?
Regards,
Malleswar
I cannot write your application for you, because it is a large project.
However, you might think about making your own login UIView as a child view of a UIViewController, which contains form elements:
This view controller is the root view controller in a UINavigationController stack.
The user enters her credentials into this form.
On clicking Submit, you push another UIViewController on to the navigation stack that contains a UIView child, that itself has a UIProgressIndicatorView and a UIWebView as children views.
The progress indicator view does its spinning wheel thing while the web page loads with the user's credentials entered in step 2.
Once the web page finishes loading, it fires its delegate method telling you loading has finished. This delegate method tells the progress indicator view to stop spinning and hide.
I would recommend reading up on UINavigationController through Google and Apple's ample documentation and sample projects. One sample project template is included in Xcode, as well.

Writing a simple image browser using UIImagePicker

I would like to write a simple image browser. User taps a button, UIImagePicker springs up, user selects photo, large detail gets displayed, user taps a ‘back’ button and is back in the picker. Everything is quite easy except the last part, the returning to the picker. The picker is a modal view, so that I have to dismiss it in order to display the picture detail. Once I dismiss it, though, I cannot easily return to it. (I’d have to reopen it and user would get back to the index instead of the last album open.) I tried keeping the picker open, but then my navigation controller’s pushViewController method does not work when I try to push the picture detail. What am I doing wrong? How would you write such a simple gallery?
Oh, that was easy. I have to push the picture detail onto the picker, not on the main navigation controller.