我试图弄清楚当用户将文本字段留空时如何在按钮按下时使文本摇动.
我目前有以下代码工作:
if self.subTotalAmountData.text == "" {
let alertController = UIAlertController(title: "Title", message:
"What is the Sub-Total!", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default,handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
} else {
}
Run Code Online (Sandbox Code Playgroud)
但我认为将文本字段震动作为警报会更具吸引力.
我找不到任何动画文本字段的动画.
有任何想法吗?
谢谢!
我使用动画来指定提示以帮助延迟交互使用这些:
let delay = 1.8 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue()) {
//call the method which have the steps after delay.
self.rain.alpha = 0
UIView.animateWithDuration(5, animations: {
self.rain.alpha = 1
})
self.tip.startAnimating()
}
Run Code Online (Sandbox Code Playgroud)
但是,如果在动画开始之前,用户触摸屏幕,我需要停止此延迟过程.
我通过传递模型视图矩阵数组来使用实例化渲染.特定制服的最大阵列尺寸是多少?
是否可以在精灵上放置物理体?我只希望精灵节点的某个部分进行碰撞检测,而不是整个图像。
这是我的物理身体
physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: CGFloat(54.0), height: CGFloat(100.0)))
Run Code Online (Sandbox Code Playgroud)
但我想将物理体放置在节点的顶部,它通常被放置在节点的中间。
如何在 swift 中的 ui 滑块上舍入或设置 5000 的间隔?
@IBAction func incomeSliderChanged(sender: UISlider) {
var incomeValue = Double(sender.value)
currentIncomeLabel.text = ("$\(incomeValue) /yr")
}
Run Code Online (Sandbox Code Playgroud) 我有一个表,当我点击一个单元格时,我希望能够访问该单元格,这样我就可以更改该单元格的某些属性,但由于某种原因,它每次都会创建一个新单元格.我可以说这是因为- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier每次点击一个单元格时都会调用它.
这是我创建单元格的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"AccountsCell";
NSLog(@"AccountsTableViewController : cellForRow");
AccountsTableViewCell *cell = (AccountsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (nil == cell)
{
cell = [[AccountsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[cell setCurrentAccount:[self.accounts objectAtIndex:indexPath.row]];
cell.delegate = self;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
并选择一个单元格:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
AccountsTableViewCell *cell = (AccountsTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
}
Run Code Online (Sandbox Code Playgroud)
有没有人知道为什么每次创建一个新单元格而不是给我一个被挖掘的单元格的引用?
我非常感谢任何帮助.
ios ×5
swift ×4
iphone ×2
animation ×1
dispatch ×1
objective-c ×1
opengl-es ×1
sprite-kit ×1
uislider ×1
uitableview ×1
uitextfield ×1