I have a viewcontroller which i am showing as a popup. The popup has two textfields with dropdown(the dropdown is a tableview which is subview of superview).So whenever I show the dropdown it is just taking the height of popup and the complete dropdown is not visible so the user is not able to select value from last rows.So I want to show the dropdown in front of all views so that the complete dropdown will be visible and the user will be able to select any value. I tried [self.view bringSubviewToFront:self.tableView]; and self.tableView.layer.zPosition = 1; both did not help me. How to do this?
Here is the screenshot
Add tableView to the window.
let window = UIApplication.sharedApplication().keyWindow!
window.addSubview(tableView)
Related
In whatsapp, when we go to any particular user then at right corner there is more option (three dots menu). Then after clicking that menu, one list will come and again at last row there is navigate arrow, then after clicking on that row again new menu will come.
here is the images,
after clicking on more option, following view will appear
I want to implement this feature in my iOS Project. Anyone have any idea how to implement it ?
You can manage it with multiple ways!
First Way : Take two table view for the menu. Initially keep one tableview hidden. Then on more's click of first tableview, show second tableview and hide firt one.
Second Way : Take only one tableview and reload different data. I mean on click of main change your datasource for tableview and reload it.
DropDown menu's are considered bad practice in iOS. Use one UIAlertController to show first options, than on selecting the More show another UIAlertController.
Heloo all,
I am new to ios swift. I have one problem in my screen.
I have one screen with drop down list of option like : current bill,water bill., bike bill, loan bill, phone bill....so on
I have sone this. But what i need is, whenever i select any option from drop down list. I need to show some ui elements like label, text filed, text box, lie that dynamically for each each selction in drop list.
For example :
if i select water bill, then below my drop down, i need to show the two label ui with name , id.
if i select current bill , then below my drop down , i need to show one text filed with place holder ' enter current bill number'
So like wise when ever i select any option from drop down..i need to show some dynamic ui.
How can i achive that ??
ANY HELP WILL BE USE FULL
You can make use of container views to achieve that:
1- Add your drop down menu to any view controller you want.
2- Add a container view under that drop down menu and using auto layout make that container view fill the place that you want it to be switchable/dynamic.
3- Redo step 2 as many times as the items of the drop menu.
4- Create IBOutlets for each of your container views and and an IBAction for your drop down menu.
5- In the IBAction of your drop down menu, set isHidden property of one container view to false and set it to true for the others based on the user's selection from the drop down menu.
Here is a tutorial that explains that with a simple example.
Just drag and drop viewcontrollers in your storyboard for your current bill,water bill., bike bill, loan bill, phone billetc.
And when ever you change the option from your drop down list use below code to add your required controller as child controller.
let currentBill = self.storyboard?.instantiateViewController(withIdentifier: "currentBill") as! CurrentBillVC
// remove other views
for k in 0..<self.parentView.subviews.count {
self.parentView.subviews[k].removeFromSuperview()
}
self .addChildViewController(currentBill)
// Add view to your maincontroller i named it parent view in which you want to display other controller w.r.t your drop down list.
self.parentView .addSubview(currentBill.view)
currentBill.didMove(toParentViewController: self)
I am using this code: click here that "simulates" a dropdown menu as it works in html code.
I have programatically added the UITextField to my navigationItem using:
[self.navigationItem setTitleView:myUITextField];
My view is a UITableView and my controller therefore inherits from UITableViewController.
I have filled the table view with a number of rows of data. I have also set up the dropdown to act on a click in my "myUITextField" and the dropdownlist appears correctly when the textField is clicked.
My problem is that if I scroll down in my list of rows on the screen and then click again on my textField then I can only see the bottom of the "dropdown" - so the dropdown list "curtain" is somehow measured to only appear at the top of the screen.
How can I fix this ? I reckon I need to fix the source code here to get it fixed.
I have a split view app that displays a thumbnail image and a button for continuing to the full view. The label, right now, is just there to make sure that the button works because I have yet to connect the full view. When the app first opens, the image is not displayed since the user has not selected an image at that point, but the button (and label) are displayed anyway. How can I get the button and label to be displayed only once a user has selected which image to view from the table?
Change default settings in Interface Builder for the button to start out as hidden, and also make sure that it starts out disabled so that users don't accidentally click it without knowing that its there, then add the following code to where you detect whether or not the image has been selected.
yourButton.enabled = YES;
yourButton.hidden = NO;
Let me know how that works out for you!
-Karoly
I have a custom menu item (UIMenuItem) attached to a UIWebView. When the user selects my custom menu item after selecting some text in the web view, I want to "deslect" the current text selection. The problem is that the edit menu will pop up again when I show a modal form for some reason, I think because there is still a selected (highlighted) text range. I want to programmatically "unselect" the selected text in my custom menu item handler, after I've captured the selected range.
Use UIView's userInteractionEnabled property. Just disable user interaction and enable it back.
Like this:
myWebView.userInteractionEnabled = NO;
myWebView.userInteractionEnabled = YES;
A cleaner solution:
Swift
webView.endEditing(true)
Objective-C
[webView endEditing:YES]