这是我以编程方式创建按钮的代码:
NSArray *buttonImage=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
[UIImage imageNamed:@"Cover_1.png"],
[UIImage imageNamed:@"Cover_2.png"],
[UIImage imageNamed:@"Cover_3.png"],
[UIImage imageNamed:@"Cover_4.png"],
[UIImage imageNamed:@"Cover_5.png"],
[UIImage imageNamed:@"Cover_6.png"],
[UIImage imageNamed:@"Cover_7.png"],nil];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 200.0f, 200.0f);
[button setTitle:[NSString stringWithFormat:@"%i", index] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
button.titleLabel.font = [button.titleLabel.font fontWithSize:50];
[button setImage:buttonImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
return button;
Run Code Online (Sandbox Code Playgroud)
但是在运行它时我无法进入模拟器并且它会抛出一个Signal Sigabart错误.有人可以帮忙吗?
是否可以通过JavaScript在浏览器上创建MP4视频?(我知道Flash现在可以使用FlashyWrappers)
理想情况下,我将用图像帧(原始,PNG或任何东西)喂它,它将把它们组合成MP4视频.
编辑:我希望在客户端创建视频,而不是向服务器提供图像数据.
所以,我选择在我的邮件扩展贴纸包中不使用故事板.iMessage应用程序附带一个storyboard文件和一个MessagesViewController.swift.我创建了两个名为CollectionViewController和StickerCell的文件.我们的想法是将CollectionViewCell子类化并将其转换为MSStickerView,并将该视图作为"单元格"出列到我的CollectionView中.
以下是将"StickerCell"设置为MSSstickerView的代码:
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let item = data[indexPath.row]
return deQStickerCell(for: item, at: indexPath)
}
private func deQStickerCell(for sticker: MSSticker, at indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView?.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! StickerCell
cell.stickerView.sticker = sticker
return cell
}
Run Code Online (Sandbox Code Playgroud)
和我的StickerCell类中的代码:
class StickerCell: UICollectionViewCell {
var stickerView: MSStickerView!
}
Run Code Online (Sandbox Code Playgroud)
我猜这个问题就在这里,因为我已成功完成了故事板和StickerClass中的确切代码,除了var是一个IBOutlet.很明显有些东西没有连接到CollectionView,或者我错过了一步.在Interface Builder中,我将创建CollectionViewController,给它一个CollectionView,给它一个CollectionViewCell,然后在顶部打一个UIView并将它的类改为MSStickerView.
如何以编程方式重新创建Interface Builder工作流程?
programmatically-created swift msstickerview mssticker imessage-extension
我需要一些关于VBA的帮助.在我的代码中,我添加了一个excel表并重命名它并向其添加一个验证列表.我需要在该验证列表中更改值时运行一些代码.并且必须仅在更改该特定单元格时运行.如果我不清楚请告诉我.请帮我解决这个问题.
我知道如何打开软键盘甚至处理其关键事件.我需要打开数字键盘.
PS我没有在布局文件中使用Edittexts.
这是我用来以编程方式打开键盘的代码
if (PasscodeLockUpdated.this != null) {
PasscodeLockUpdated.this .getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);}
Run Code Online (Sandbox Code Playgroud) android numeric-keypad android-softkeyboard programmatically-created
在我的代码中,我以编程方式向我的Layout添加了radioButtons,checkboxes等输入元素.问题是,这些元素的样式不是你可以获得的默认样式,当你通过xml添加let说一个radioButton时.(它在白色应用程序背景上看起来非常白,几乎透明.有点像它是透明的)另外,我添加的EditText元素具有相同的样式,如果你在其中键入内容,文本太大了重叠文本行.所以我猜这一切都归结为以某种方式给这些元素提供了默认样式,就像它们通过xml定义时一样.
我的代码示例如下所示:
RadioGroup radioGroup = new RadioGroup(mContext);
radioGroup.setLayoutParams(fullWidthWrapHeight);
for (int i = 0; i < arg0.getOptions().size(); i++){
RadioButton radioButton = new RadioButton(mContext, null);
radioButton.setPadding(padding16dp , padding8dp, padding16dp, padding8dp);
radioButton.setText(arg0.getOptions().get(i).getText());
radioButton.setLayoutParams(wrapBoth);
radioButton.setGravity(Gravity.CENTER_HORIZONTAL);
radioButton.setTextAppearance(mContext, R.style.Default_Text);
radioGroup.addView(radioButton);
}
Run Code Online (Sandbox Code Playgroud)
我的目标API lvl是21(Lollipop)
我以编程方式添加按钮,按钮的数量取决于某些条件.要为RelativeLayout.LayoutParams添加规则,将Buttons对齐到彼此的顶部,我需要设置它们的ID.从2 - 3年前的所有答案都说setId(int)是可以的(例如setId(1)),但是现在它被禁止了(UPD.只有int literals它才行.用int变量一切都好.想知道为什么).现在怎么办?
我遇到一种情况,我想以编程方式更改我的文本视图的重力(Gravity.CENTER_HORIZONTAL| Gravity.BOTTOM到Gravity.START| Gravity.BOTTOM)。当前,我正在使用该setGravity()方法,但我想知道是否有任何方法可以将其设置为平滑过渡到新位置,而不仅仅是跳到新的离散位置。
谢谢,休
我想要一个添加UITextView到UIStackView编程,但它不会出现在屏幕上.
当我检入调试视图层次结构时,它位于视图层次结构中,它有一些约束但不会显示在输出视图中.
这是我的代码:
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: .Normal)
button.setImage(UIImage(named:"image2"), forState: .Selected)
textView.textAlignment = NSTextAlignment.Left
textView.textColor = UIColor.blackColor()
textView.editable = true
textView.text = ""
stackView.addArrangedSubview(textView)
stackView.addArrangedSubview(button)
Run Code Online (Sandbox Code Playgroud)
按钮添加正常.但我找不到正确显示TextView的方法!尝试添加如下所示的宽度/高度限制,但它不起作用,或工作不当(取决于变体):
let widthConstraint = NSLayoutConstraint(item: textView,
attribute: NSLayoutAttribute.Width,
relatedBy: NSLayoutRelation.Equal,
toItem: stackView,
attribute: NSLayoutAttribute.Width,
multiplier: 1,
constant: 0)
stackView.addConstraint(widthConstraint)
let heightConstraint = NSLayoutConstraint(item: textView, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: stackView, attribute: NSLayoutAttribute.Height, …Run Code Online (Sandbox Code Playgroud) 我需要以编程方式启用/禁用Automatically show the touch keyboard在Windows 10与WPF(不是UWP)选择喜欢的是显示在这里.
我找不到任何东西.我可以使用C#或注册表项中的任何API,我可以修改以启用/禁用它吗?
c# wpf on-screen-keyboard programmatically-created windows-10
android ×4
ios ×2
swift ×2
c# ×1
encoder ×1
excel ×1
excel-vba ×1
gravity ×1
iphone ×1
javascript ×1
mp4 ×1
mssticker ×1
uibutton ×1
uistackview ×1
uitextview ×1
validation ×1
vba ×1
view ×1
windows-10 ×1
wpf ×1