为什么0代表java.lang.Class.forName0?(Why does the 0 represent in java.lang.Class.forName0? [duplicate])
这个问题在这里已有答案:
我熟悉Java异常的基本结构,但是我第一次注意到Class.forName stacktrace的奇怪之处:
java.lang.Class.forName0(Native Method) java.lang.Class.forName(Class.java:195) ... java.lang.Thread.run(Thread.java:745)
为什么提到了两个forName实例,零表示什么? 这是堆栈跟踪如何表示具有不同签名的多个同名方法吗?
This question already has an answer here:
I'm familiar with the basic structure of Java exceptions, but for the first time I noticed an oddity with a Class.forName stacktrace:
java.lang.Class.forName0(Native Method) java.lang.Class.forName(Class.java:195) ... java.lang.Thread.run(Thread.java:745)
Why are there two forName instances mentioned, and what does the zero represent? Is this how stacktraces represent multiple methods of the same name with different signatures?
原文:https://stackoverflow.com/questions/48911403
最满意答案
您需要将视图存储到属性中,然后在每次触发计时器事件时枚举该属性
var sprites: [UIImageView]? override func viewDidLoad() { super.viewDidLoad() var sprite = UIImage(named: "sprites/areaLocatorSprite.png")! var locations:NSArray = animal[eventData]["locations"] as NSArray self.sprites = map(locations) { var locationx = $0["locationx"] as String var locationy = $0["locationy"] as String let x = NSNumberFormatter().numberFromString(locationx) let y = NSNumberFormatter().numberFromString(locationy) let cgfloatx = CGFloat(x!) let cgfloaty = CGFloat(y!) var mapSprite = UIImageView(image: sprite) mapSprite.frame = CGRectMake(cgfloatx,cgfloaty,10,10) townMap.addSubview(mapSprite) return mapSprite } timer = NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, selector: Selector("flash"), userInfo: nil, repeats: true) } func flash() { if let sprites = self.sprites { for sprite in sprites { sprite.alpha = sprite.alpha == 0 ? 1 : 0 } } }
You need to store the views into a property and then enumerate that property each time your timer event is fired
var sprites: [UIImageView]? override func viewDidLoad() { super.viewDidLoad() var sprite = UIImage(named: "sprites/areaLocatorSprite.png")! var locations:NSArray = animal[eventData]["locations"] as NSArray self.sprites = map(locations) { var locationx = $0["locationx"] as String var locationy = $0["locationy"] as String let x = NSNumberFormatter().numberFromString(locationx) let y = NSNumberFormatter().numberFromString(locationy) let cgfloatx = CGFloat(x!) let cgfloaty = CGFloat(y!) var mapSprite = UIImageView(image: sprite) mapSprite.frame = CGRectMake(cgfloatx,cgfloaty,10,10) townMap.addSubview(mapSprite) return mapSprite } timer = NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, selector: Selector("flash"), userInfo: nil, repeats: true) } func flash() { if let sprites = self.sprites { for sprite in sprites { sprite.alpha = sprite.alpha == 0 ? 1 : 0 } } }
相关问答
更多-
动画旋转UIImageView(Animate Rotating UIImageView)[2022-02-02]
我使用这样的代码来实现类似的效果(尽管我将它旋转了360度): CABasicAnimation *rotate; rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; rotate.fromValue = [NSNumber numberWithFloat:0]; rotate.toValue = [NSNumber numberWithFloat:deg2rad(10)]; rotate.duration = 0. ... -
如何在obj c中拖动动态创建的UIImageview(xcode)(how to drag dynamically created UIImageview in obj c (xcode))[2022-05-07]
我对你如何创建UIImageViews感到有点困惑,因为你使用的是for循环而是静态名称。 所以你可能有15个名为“imageView1”的UIImageViews。 但无论如何,如果您使用链接到的问题中的代码,这根本不重要。 也许你把线条排除在外......这是正确的顺序。 (如果它不起作用,请告诉我,以及你得到的错误) //-(void)ViewDidLoad? {???? is this your function?? int xvalue = 0;//?? not sure where yo ... -
Swift 3/4如何为UIImageView的contentMode制作动画(Swift 3/4 How to animate contentMode of UIImageView)[2022-12-09]
contentMode本身不是可动画的属性。 但是你可以在具有transition(with:duration:options:animations:completion:)的视图的两个不同再现之间进行动画处理transition(with:duration:options:animations:completion:) ,例如 @IBAction func didTapButton(_ sender: UIButton) { let contentMode: UIViewContentMode = ... -
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Trend"]]; imageView.frame = CGRectMake(....) or imageView.center = CGPointMake(...) 将此视图添加到容器视图中,即[myView addSubview:imageView]; UIImageView *imageView = [[UIImageView allo ...
-
您不需要在animateWithDuration使用CAffineTranform ,您可以简单地定义新中心,如: let oldCenter = image.center let newCenter = CGPoint(x: oldCenter.x - 100, y: oldCenter.y) UIView.animate(withDuration: 1, delay: 0, options: .curveLinear, animations: { image.center = newCenter ...
-
使用NSValue(CGPoint: cgpiont)而不是NSValue.valueWithCGPoint(<#point: CGPoint#>) ,这在swift中已弃用。 NSValue(CGPoint: cgpiont)是给定的构造函数,可以用来将NSValue中的CGPoint转换为NSValue 。以下代码可以工作 func moveImage(view: UIImageView){ var toPoint: CGPoint = CGPointMake(0.0, -10.0) v ...
-
Swift 3 UIImageView订单(Swift 3 UIImageView Order)[2024-05-14]
您需要将imageView放在最前面,而不是self.view。 self.playerImages[self.currentPlayer].bringSubview(toFront: imageView!) You need to bring the imageView to the front and not self.view. self.playerImages[self.currentPlayer].bringSubview(toFront: imageView!) -
UIView.animateWithDuration(1, delay: 0, options: .CurveLinear, animations: { UIImageView.center = CGPointMake(UIImageView.center.x, UIImageView.center.y + 200); }, completion: { (finished: Bool) in move(); }); 这是如何。 UIView.animateWithDuration( ...
-
实现这一目的的一种方法是,您可以首先添加一个视图,并将该视图颜色设置为grayColor ,并在开始时将其隐藏起来,并将其alpha设置为0.8,并且当侧边栏出现时显示该视图以及侧栏隐藏时可以隐藏该视图。 这是一个简单的示例代码: import UIKit class ViewController: UIViewController, sideBarDelegate { var sideBar : SideBar = SideBar() @IBOutlet weak var Trans ...
-
您需要将视图存储到属性中,然后在每次触发计时器事件时枚举该属性 var sprites: [UIImageView]? override func viewDidLoad() { super.viewDidLoad() var sprite = UIImage(named: "sprites/areaLocatorSprite.png")! var locations:NSArray = animal[eventData]["locations"] as NSArray self.s ...