programmatically-created

Display UISearchController's searchbar programmatically

。_饼干妹妹 提交于 2019-12-18 04:14:46
问题 Note 1: This question pertains to adding a UISearchController's search bar outside of the table view it updates - NOT as the table view's header. Note 2: Some trial and error led me to a solution. Please see my answer below. I am new to iOS development and am struggling to work with the UISearchController class. I have a view controller, and in my view controller's view, I plan to have a search bar above a table view. I would like the search bar to be linked to a UISearchController. Since

How do you add an action to a button programmatically in xcode

左心房为你撑大大i 提交于 2019-12-17 10:17:50
问题 I know how to add an IBAction to a button by dragging from the interface builder, but I want to add the action programmatically to save time and to avoid switching back and forth constantly. The solution is probably really simple, but I just can't seem to find any answers when I search it. Thank you! 回答1: Try this: Swift 4 myButton.addTarget(self, action: #selector(myAction), for: .touchUpInside) Objective-C [myButton addTarget:self action:@selector(myAction) forControlEvents

Add a multiple buttons to a view programmatically, call the same method, determine which button it was

无人久伴 提交于 2019-12-17 07:14:58
问题 I want to programmatically add multiple UIButtons to a view - the number of buttons is unknown at compile time. I can make one or more UIButton's like so (in a loop, but shorted for simplicity): UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Button x" forState:UIControlStateNormal]; button.frame = CGRectMake(100.0, 100.0, 120.0, 50.0); [view addSubview

Is there a way to programmatically scroll a scroll view to a specific edit text?

邮差的信 提交于 2019-12-17 02:55:17
问题 I have a very long activity with a scrollview. It is a form with various fields that the user must fill in. I have a checkbox half way down my form, and when the user checks it I want to scroll to a specific part of the view. Is there any way to scroll to an EditText object (or any other view object) programmatically? Also, I know this is possible using X and Y coords but I want to avoid doing this as the form may changed from user to user. 回答1: private final void focusOnView(){ your

Android: How to set LinearLayout marging programmatically

拈花ヽ惹草 提交于 2019-12-13 06:17:13
问题 I've been trying to set margins for a programmatically created LinearLayout LinearLayout linearLayout = new LinearLayout(this); setMargins(linearLayout,20,20,20,20); private void setMargins (View view, int left, int top, int right, int bottom) { if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); final float scale = getBaseContext().getResources().getDisplayMetrics().density; // convert

Expanding button to x,y positions

[亡魂溺海] 提交于 2019-12-13 03:50:03
问题 Here are my two buttons: http://prntscr.com/hos2hz (Ignore the dotted line) I want the GREEN button to expand with an animation to fill the whole of the view (highlighted in red): http://prntscr.com/hos3hm If the answer could be programmatically, rather than XML, that would be fantastic. I would imagine it would be something to do with expanding to its parent view, or more likely to an X,Y,Width,Height position, but I'm not quite sure. All help is greatly appreciated :) 回答1: You can do

TestNG: how do I run a custom TestNG.XML File programmatically

家住魔仙堡 提交于 2019-12-12 16:03:22
问题 I browsed through several different threads and websites (as well as the TestNG API) looking for how to run and create custom tests. I haven't found (or not understood) how I can run a custom testng.xml (test suite) programmatically. I have created a testng.xml file looking like this: <?xml version="1.0" encoding="UTF-8"?> <suite name="The Login Suite'" verbose="1" > <test name="Some login check" > <classes> <class name="tests.first_login"/> </classes> </test> <test name="Another login check"

iphone: UIScrollView Paging enabled with NO ZOOM and NO PREVIEW

限于喜欢 提交于 2019-12-12 05:36:34
问题 i want to implement a UIScrollView where paging is enabled and i can just flick through some images. Thats all i want to be able to do for now. I have done this so far in interface builder: can someone help? I dont know how to do the rest. Can someone please help me with this. I dont need any zooming functionality. I dont want any preview of the previous or next image within the scrollview, i just want a simple paging enabled scroll view that allows a user to flick through images. All help is

Change width to a IBOutlet (UIImageView)

我们两清 提交于 2019-12-12 02:46:36
问题 I was doing some experiments with Xcode an a little question comes to my mind: that is how I could change size of an UIImage created by storyboard. below the code I used: @IBOutlet var label: UILabel! @IBOutlet var img: UIImageView!//x=0, y=0, w=50, h=50, red, created in the storyboard var numero = 11 override func viewDidLoad() { super.viewDidLoad() if numero < 10 { label.text = "\(numero)" img.backgroundColor = UIColor.blueColor() } else if numero > 10 { label.text = "\(numero)" img.frame =

How to update linearlayout child view programmatically in android?

拈花ヽ惹草 提交于 2019-12-11 11:52:57
问题 I have created linearylayout programatically. where it has multiple rows created having white background. Now if I click on any row then only that row's imageview icon should be changed(should be green) and other row's imageview background should be changed to white. Is there any substitude of notifyDataSetChanged for linearlayout in android. below is my code. for (int i = 0; i <= obj_tribe_info.al_ethnicity_secondary.size(); i++) { final int position = i; al_eth_bool.add(false); final