programmatically-created

Programmatically placing collectionView in view

我是研究僧i 提交于 2019-12-11 05:02:51
问题 I want to place a collectionView programmatically between a navigationBar, a label and the tabBar on the bottom. I do not want to have any spacing between the different parts, how do I correctly ad the views to the view? Whats the best way to do it? import UIKit private let reUseIdentifierCollectionView = "CollectionViewCell1" class CVControllerViewController: UIViewController { var heightNavigationBarTop: CGFloat{ get{ let barHeight = self.navigationController?.navigationBar.frame.height ??

Is it possible to add done button inside the keyboard in iphone?

蹲街弑〆低调 提交于 2019-12-11 04:39:34
问题 Currently i am working in iPhone application, Using UITextField to enter phone number, user enter the phone number, then how to hide the keyboard? because no return button here, Is it possible to add done button inside the keyboard, please help me Thanks in Advance 回答1: Here is to be a good tutorial about this. 回答2: Refer this link. It shows how to add "Done" button in key board. But I would suggest you to use inputAccessoryView instead. Refer this SO post. And Must read this SO answer. 回答3:

Programmatically connecting multiple views set to any size using ConstraintLayout

*爱你&永不变心* 提交于 2019-12-11 03:39:11
问题 I'm using ConstraintLayout beta4 and trying to create a horizontal chain across the screen programmatically. The problem I'm running into is when I connect multiple views together in a chain across the screen (ex: Left side of layout <-> leftButton <-> rightButton <-> Right side of layout) then nothing shows up at all. Here is the code that does not work: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate

XCode: Add multiple buttons programmatically with specific names and animate

空扰寡人 提交于 2019-12-11 03:15:54
问题 I just read this post about adding buttons with a loop programmatically. I want to do the same thing, but do it with a name for each one, and animate them the same way. Is this a good idea, or should I just copy the same line of code for each button? Further, I'd like to add a number of buttons (say four) from a list of names (greater than four) and pick them randomly. The catch is, I need them to be named properly and pull images associated with each name. Any ideas? Thanks SO community! 回答1

Getting exception while setting layoutparams of scrollview programmatically

别等时光非礼了梦想. 提交于 2019-12-10 19:20:39
问题 I am getting exception while setting the layoutparams of scroolview programmatically.I have tried but getting exception while doing that.This is the code: sv = (ScrollView)findViewById(R.id.scrollView); sv.setBackgroundColor(Color.TRANSPARENT); ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams( ScrollView.LayoutParams.MATCH_PARENT, ScrollView.LayoutParams.MATCH_PARENT); layoutParams.bottomMargin = 100; layoutParams.setMargins(0, 0, 0, 100); sv.setLayoutParams(layoutParams);

android - set ID to the view programmatically

对着背影说爱祢 提交于 2019-12-10 04:22:46
问题 I'm adding Buttons programmatically and the number of Buttons depends on some conditions. To add rules for RelativeLayout.LayoutParams that Buttons be aligned to the top of each other I need to set their IDs . All the answers from 2-3 years ago say that setId(int) is okay (e.g. setId(1) ) but now it's forbidden ( UPD . it's not ok only with int literals. With int variables everything is ok. Wonder why). How to do it nowadays? 回答1: According to the API it's not forbidden or deprecated. Here is

Web API 2 Is it possible to load a route/controller programmatically?

旧时模样 提交于 2019-12-09 10:43:44
问题 I am currently working on an enterprise web application that uses WCF to implement a REST API. It utilizes a VirtualPathProvider to catch requests to *.svc files (which don't actually exist), and then builds them on the fly to dynamically load the associated WCF services. This allows the system to have "modules" that can be added to the application at runtime without impacting the web server or anyone using it. What I would like to know, is if the same is conceptually possible with Web API 2.

create a UITableViewController programmatically in Swift

醉酒当歌 提交于 2019-12-08 18:55:42
问题 I'm trying to, as the title say, set up a UITableViewController programmatically. After a few hours of trying I hope someone can help me. And, yes, I hve checked out other posts on this matter: import UIKit class MainViewController: UITableViewController { init(style: UITableViewStyle) { super.init(style: style) // Custom initialization } override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources

Changing UITableViewCell's width constraint's constant value for each instance

送分小仙女□ 提交于 2019-12-08 09:21:38
问题 I am trying to create a chat application where in I have made a custom UITableViewCell using only code. So it is like a bubble with Name, message and time labels inside the bubble in the same order. The name label should be half of the total bubble's width and the bubble's width is determined by the width of the message whose maximum width is 220.0f after which it will go to next line. The problem that I am facing is: I am trying to change the name label's width constraint's constant

UITextView added from code missing in UIStackView

↘锁芯ラ 提交于 2019-12-07 06:05:38
问题 I'm trying to add a UITextView to UIStackView programatically, but it doesn't appear on the screen. When I check in Debug View Hierarchy, it is in the view hierarchy and it has some constraints but doesn't show up in the outputted view. This is my code: let stackView = UIStackView() let textView = UITextView() let button = UIButton() stackView.axis = .Horizontal stackView.spacing = 20 stackView.distribution = UIStackViewDistribution.Fill button.setImage(UIImage(named:"image1"), forState: