Webview actionsheet cancel button closes the ViewController - swift

In webview (be it UIWebview or WKWebview) I have an attachment button on which when clicked will open an actionsheet to open camera or choose images from library and a default cancel button.
When the app is installed for the first time, clicking on this attachment button brings up the actionsheet and when I choose cancel, then viewWillDisappear and viewDidDisappear of the present VC which has this webview is called and a VC from another storyboard is displayed (I have 3 storyboards in total) - (See update)
Again I have to pass through different VCs to get to this webview and if i again click on actionsheet and now if i select either options, 'from library', 'from camera' or 'cancel' option the same problem persists.
But when the app is stopped or quit from the background and is run again, this issue seems to vanish off.
Could yo pls let me know what am I doing wrong here or is there anything that can be done as a workaround???
Update - Actionsheet cancel button when clicked gets back to a ViewController which has no TabbarController or Navigation bar or both.
I made a sample with each one seperately and found the same issue with either of them.
Note: This is done in Swift 2.3

This issue is fixed in iOS 11.
It can be solved by pushing the WKWebview controller or changing the presentation style of the modal presentation to be currentContext.

Related

Storyboard iOS5 - How to prevent the storyboard changing when pressing the Segue button

I've created an app using the new iOS 5 Utility app template. Since the previous SDK, we now have to use storyboards for the GUI (which I do like using) but I am wondering how to prevent the "Segue" from flipping the view to the next view on the storyboard.
By default there is a button which when pressed flips to the "FlipsideViewController" and I would like to use this button as part of a login form but I need to stop the storyboard going to the Segue unless the credentials are correct. I have all my login code written but cannot prevent the page from flipping. The method I thought would do this actually prevents the user from going back by clicking the default "Done" button on the "FlipsideViewController".
Can anyone help?
You have to connect the button to an IBAction instead of a segue. In the action, check if the credentials are correct, then call performSegue: to perform it.
You will have to connect the segue directly from the view controller to the next scene instead of from the button.

iOS5 - Storyboard - showing another view

This is simple one though:
I'm having XCode 4.2 with iOS beta7. I am just trying a to have to views with one button in first view. On click of button, it will show next view.
In many tutorials, when I click and drag the button to next view, it will show "performSegueWithIdentifier:sender:" view.
But in my interface builder, its showing "Storyboard Segues with Push, Modal, Popover, Custom......"
I don't know whether I'm doing wrong or its the behavior of the xcode itself....
can some one suggest me good tutorials for iOS5 storyboard please?
Yes, you doing everything right. Push, Modal are types of showing next screen (UIView). You need to select it according Human Interface Guidelines from Apple.

problem with iOS 4.2 when user press the list view item to go to UIwebview page and the navigation button disappears on the second visit

My app is a Navigation based application. The main menu contains the list view items. if I clicks one of them, it goes to next view which in this case take me to UIwebview embedded web site. Everything is looking great. I can view the content of web page, the navigation control back button which takes to the main menu if I press it. However, I'm having issue when I try to go back to main menu if i visit that subview the second time. It loads the content of UIwebview web page, but the navigation button is gone and won't let me go back to main menu. This problem only appears on latest iOS 4.2 version. Otherwise it works great on 3.1 to 4.1. I would appreciate any hints or inputs.
Note this seems not working for subview using UIWebview embedded web content. I don't have any issue with other subviews
Can you show us the code ? Did you try this: self.navigationItem.hidesBackButton = NO; in viewDidLoad method where you are adding UIWebView to your view..

How can I dismiss the view appeared by touching Add item in UINavigationController?

I have added add(+ symbol button) button to my navigation controller.
When I click it a view appears from bottom. I added a navigation bar and two buttons to it.
One save and one cancel button. And the view have one textEdit box. After editing I can save or cancel. If I touch cancel I need the view to disappear like it should go down again.
I think all iPhone , iPodTouch users use it. Like when they touch Add item then a view appears from bottom and when they cancel it goes down again. How can I make in this way in my application.
Maybe you're talking about a UIActionSheet?!?
http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIActionSheet_Class/Reference/Reference.html

Change UIActionSheet after doing it's job

I have to import some XML data into my app.
Now I open a UIActionSheet and add as a subview a UIActivityIndicatorView. Initially I show a progress wheel and a button with 'Cancel'.
When the XML has been imported, I want to hide the progress wheel (this it's easy) and change the button into a 'Done' button, all in the same UIActionSheet.
What I'm doing now is closing the UIActionSheet with the option dismissWithClickedButtonIndex, but I don't like this way because it's the same as pressing 'Cancel', and then I show an UIAlertView displaying "All data has been imported".
Is this possible ?
You shouldn't be doing that, when it loads correctly just dismiss the ActionSheet. On the other hand if an error occurs then display an alert.
Think about the user who will use the app multiple times a day, a Done message each time will be a waste of time.
UPDATE
As i understand your goal is to use the ActionSheet just as a popup (with Cancel ability), if so, just call dismissWithClickedButtonIndex:animated: when your XML loading is done.
If its successful then just call the dismiss method, if its unsuccessful then call the dismiss and popup an alert
This is a bit of a hack but should work. Note that there is a good chance that this will result in your app not being accepted into the app store as you're messing around with the action sheet in ways Apple didn't intend.
Initially display the action sheet with both the 'Done' and 'Cancel' buttons. Before displaying the sheet hide the 'Done' button using its hidden property. To see how to access the 'Done' button see this question.
Then when you're hiding the UIActivityIndicatorView, also change the hidden property of both the 'Cancel' and 'Done' buttons, so that the 'Done' button becomes visible. If the 'Done' button appears in the wrong position move it by modifying its centre property.