小编rak*_*hbs的帖子

在Swift中为UITextField/UIView摇动动画

我试图弄清楚当用户将文本字段留空时如何在按钮按下时使文本摇动.

我目前有以下代码工作:

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)

但我认为将文本字段震动作为警报会更具吸引力.

我找不到任何动画文本字段的动画.

有任何想法吗?

谢谢!

uitextfield ios swift

59
推荐指数
8
解决办法
4万
查看次数

停止dispatch_after

我使用动画来指定提示以帮助延迟交互使用这些:

 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)

但是,如果在动画开始之前,用户触摸屏幕,我需要停止此延迟过程.

animation dispatch swift

15
推荐指数
5
解决办法
1万
查看次数

可以在ios中传递给着色器的统一数组的最大大小是多少?

我通过传递模型视图矩阵数组来使用实例化渲染.特定制服的最大阵列尺寸是多少?

iphone opengl-es ios opengl-es-2.0

6
推荐指数
1
解决办法
2002
查看次数

是否可以将物理体仅定位到 Sprite 的一部分?

是否可以在精灵上放置物理体?我只希望精灵节点的某个部分进行碰撞检测,而不是整个图像。

这是我的物理身体

physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: CGFloat(54.0), height: CGFloat(100.0)))
Run Code Online (Sandbox Code Playgroud)

但我想将物理体放置在节点的顶部,它通常被放置在节点的中间。

ios sprite-kit skphysicsbody swift

4
推荐指数
1
解决办法
628
查看次数

如何让UISlider具有离散间隔?例如间隔 5000

如何在 swift 中的 ui 滑块上舍入或设置 5000 的间隔?

@IBAction func incomeSliderChanged(sender: UISlider) {
    var incomeValue = Double(sender.value)
    currentIncomeLabel.text = ("$\(incomeValue) /yr")
}
Run Code Online (Sandbox Code Playgroud)

uislider ios swift

1
推荐指数
1
解决办法
1973
查看次数

点击UITableView单元格正在创建一个新单元格

我有一个表,当我点击一个单元格时,我希望能够访问该单元格,这样我就可以更改该单元格的某些属性,但由于某种原因,它每次都会创建一个新单元格.我可以说这是因为- (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)

有没有人知道为什么每次创建一个新单元格而不是给我一个被挖掘的单元格的引用?

我非常感谢任何帮助.

iphone objective-c uitableview ios

0
推荐指数
1
解决办法
296
查看次数