初心者アラート!:) 私のアプリには複数のビューがあり、すべてがストーリー ボードに設定されており、すべて独自のサブクラス化された UIView クラスと、独自の上書きされた drawRect メソッドがあります。そのうちの 1 つはボタンとして機能し、setneedsdisplay を介して自身を再描画し、別の UIViews クラスの関数を呼び出すことができます。
import UIKit
class Button: UIView {
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
super.touchesEnded(touches, withEvent: event)
let touchPoint: CGPoint! = touches.anyObject()?.locationInView(self)
if butouched == true{
if touchPoint.x > bounds.size.width - bounds.size.height && touchPoint.x < bounds.size.width && touchPoint.y > 0 && touchPoint.y < bounds.size.height{
counter++
setNeedsDisplay() //thats the setNeedsDisplay that works
DrawGraph().updateModell()
}
}
}
現在の問題は、updateModelll 関数が呼び出されたにもかかわらず、この関数の setNeedsDisplay が機能しなかったことです。
import UIKit
class DrawGraph: UIView {
func updateModell() {
setNeedsDisplay() // thats the setNeedsDisplay that doesn't work
}
だから私はググってググったが、何が悪いのか分からない。はい、今週は Swift と iOS を使用する最初の週です...