WebView dismissed if choose file and select photo Library - swift3

I'm working on a project where I'm using webView and on site in webView have form where i can add file,
after need select what use, i select Photo library,
after controller will dismissed.
In Controller i use
webView.loadRequest(NSURLRequest(URL: NSURL(string: ln)!))

Set Delegate to webview.
webView.delegate = self
Then after call delegate method of webview.
func webViewDidFinishLoad(_ webView: UIWebView)
Enter your code above method of choose file and select photo Library.

Related

How to limit the accept file type with directory/png only with SwiftUI drag & drop?

I got a question about drag&drop with SwiftUI. In my case, I added an ondrop modifier to a textfield as the code:.onDrop(of: [.directory], isTargeted: nil) { providers in } , however, when I drag a folder to the textfield, it not works. but if I change the supportedContentTypes to [.fileURL] , it works. same issue with supportedContentTypes of [.png] or[.image] . How can I limit the accept file type with directory/png only?

Navigation view is hiding while pushing from SwiftUI views to Storyboard project in iOS13

I have added SwiftUI views in my existing swift project.
I have the following flow in the project
FirstViewController --NavigationPush -> SwiftUIView1 -NavigationLink->
SwiftUIView2 - NavigationLink-> SwiftUIView3 - NavigationLink
(UIViewRepresentable) -> SecondViewController.
till SwiftUIView3 everything works as expected. while pushing from SwiftUIView3 -> SecondViewController, even though I'm setting the navigation property isHidden = false,
the navigationBar appears in the controller for a fraction of sec and disappears. I have tried to unhide navigation in all the controller life cycle methods. But nothing happens. Please let me know your suggestion to resolve this.
FYI, below code, I used SwiftUI to hide the navigation bar.
Code Block
.navigationBarTitle("") // This should be empty.
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)

Titanium Hyperloop casting ListView to UIScrollView to use flashScrollIndicators

I want to flash the scrollbars of a ListView in Axway / Appcelerator Titanium. So I cast a Titanium ListView to a iOS UIScrollView and then try to call the flashScrollIndicators method on it, but I get an exception. Does anyone now how to accomplish this? See my code below:
-- View
<Alloy>
<Window onOpen="onWindowOpen">
<ListView id="listView">
etc...
-- Controller
// After displaying the ListView I call:
var UIScrollView = require('UIKit/UIScrollView');
var listView = UIScrollView.cast($.listView);
listView.flashScrollIndicators();
The $.listView object is natively a subclass of UIView, not a UIScrollView. It contains a UITableView as a child view. You could access the tableview like this:
var UIView = require('UIKit/UIView');
var listView = UIView.cast($.listView);//you cast it to be able to access it's native properties
listView.tableView.flashScrollIndicators();
Haven't tested it but I guess it should work.
When in doubt about the type of a Titanium UI element, just go and check the source code by opening the project compiled in the build/iphone directory. Open it with XCode and search for the header file.

How to setUp UiTableViewController below the battery bar

newBie here. I have added an UItableViewController into storyBoard. I use this as a setting page.
HomeVC ----> Setting VC
In code : I use the below code to bring the tableView below the battery Bar:
self.tableView.contentInset = UIEdgeInsets(top: 20,left: 0,bottom: 0,right: 0)
Problem:
How to move the TableView down below the battery bar so that I can add a button above the table in StoryBoard
Please help.
For this you should use a normal view controller and drag a table on the view controller this way you can make the table size whatever you like. This will also allow you to place buttons wherever you like.
Don't forget to assign the TableViewDataSource and TableViewDelegate to your view controller.
Good luck!
After doing some search on UiTableViewController, to use it as setting page I have to set static cell to it. This UiTableViewController will occupy the entire view.
To set the tableView below the battery icon,
use:self.tableView.contentInset = UIEdgeInsets(top: 20,left: 0,bottom: 0,right: 0)
However, No need to do so. In the first TableViewSection, you can create a few tableView cell, just leave the first cell blank which acts as a margin below the battery bar.

Button visibly clicking but event not registering

Swift 3/iOS 10/Xcode 8
I have a view controller (pieChart) that contains a label, two buttons and an empty view (which will contain a pie chart). The label and two buttons are incorporated into a horizontal stack view, which lies above the pie chart view.
The above VC is embedded into one of four container views (The main screen of the app is comprised of these four container views) when the app starts up.
In pieChart, I have linked both buttons up to their respective IBActions and IBOutlets. When clicking on button 2, a modal segue should occur to another VC but this does not happen. Visibly, the button is registering the click - ie it changes colour when you click it. I have placed a print statement in the IBAction method for button 2 but this too does not display. No error messages are displayed in console either.
The only reasons for this occurring that I have found after several hours of hunting are:
sub views have been added to the button itself so the click event signal passes by the button to be received by the added sub views. This is not the case for me. Order is Main App Window > Container View > Embedded VC > Stack View > Button. InteractionEnabled is set to true for all.
Button lies partially outside containing view (it's height/width might be greater than its containing view). This is not the case for me. The stack view, label and both buttons share the same height and the width of the stack view is equal to the sum of the widths of the label and buttons plus the spacing between the label and buttons.
I have also tried adding an event handler programmatically with:
SelectAnalyisButtonOutlet.addTarget(self, action: #selector(SelectAnalysisButtonClicked), for: .touchUpInside)
but the same outcome occurs.
Are there any other reasons for the click events seemingly not registering?
EDIT 1
The pieChart VC mentioned above is one of several VC's that are swapped out of the same container view (called detailContainerView), depending on which button (all of which work just fine) is clicked in one of the OTHER container views (called TabBar).
I placed a button in each of two other VC's that get displayed in detailContainerView and hooked them each up to an IBAction. Each IBAction contains a print statement that fires when the button is clicked. At the moment then, these two VC's only consist of a label and the newly inserted buttons. None of the buttons worked when I ran the app.
I then set one of the VC's of detailContainerView as the Initial View Controller in the Attributes Inspector and re-ran the app. Suddenly the buttons now work! If I then hook the buttons up to a segue, the segues work too!
Something seems to change when I swap out the VC's in detailContainerView. The code I am using to swap the VC's out is as follows:
func SwapOutControllers(vc: UIViewController, vcName: String){
//REMOVE OLD VC
detailPaneVCReference?.willMove(toParentViewController: nil)
detailPaneVCReference?.view.removeFromSuperview()
detailPaneVCReference?.removeFromParentViewController()
var newVc: UIViewController?
switch vcName {
case "Biography":
newVc = vc as! Biography
case "Social Media":
newVc = vc as! SocialMedia
case "News Feed":
newVc = vc as! NewsFeeds
case "Stats":
newVc = vc as! StatsAboutParliament
case "Petitions":
newVc = vc as! Petitions
default:
print("Error: No VC Found!")
}
//ADD NEW VC
ParentVC?.addChildViewController(newVc!)
let width = detailContainerView?.frame.width
let height = detailContainerView?.frame.height
newVc?.view.frame = CGRect(x: 0, y: 0, width: width!, height: height!)
detailContainerView?.addSubview((newVc?.view)!)
newVc?.didMove(toParentViewController: ParentVC)
}
detailPaneVCReference is a reference to whichever VC is currently being displayed by detailContainerView. ParentVC is the VC that contains the four container views.
The VC that is removed from the ParentVC still exists in the debugging view hierarchy after it has been removed/swapped out - could this be somehow blocking the click event from reaching the event handler?
SOLUTION!
The source of my problem has been that the references I had made to each of the view controllers that get swapped in and out of detailContainerView were incorrectly declared as weak references. I deleted "weak" (eg "weak var x: UIViewController?" --> "var x: UIViewController?") from each of the declarations and voila!, the code now works as intended!
The source of my problem has been that the references I had made to each of the view controllers that get swapped in and out of detailContainerView were incorrectly declared as weak references. I deleted "weak" (eg "weak var x: UIViewController?" --> "var x: UIViewController?") from each of the declarations and voila!, the code now works as intended!