私はStanford Open-University のiPhone 開発コースをフォローしていますが、課題3 で 2 日間ブロックされています。
タスクは次のとおりです。
- PolygonShape オブジェクトを表示するカスタム UIView サブクラスを作成します。
- ビュー クラスに PolygonShape オブジェクトへのアクセス権を付与して、必要に応じてポリゴンの詳細を取得できるようにします。
問題は、コントローラで定義されたポリゴン オブジェクトへのアクセスをビュー クラスに与えるにはどうすればよいかということです。
それが役立つ場合、これが私の実装です:
CustomView.h:
#import "PolygonShape.h"
@interface CustomView : UIView {
IBOutlet PolygonShape *polygon;
}
- (NSArray *)pointsForPolygonInRect:(CGRect)rect numberOfSides:(int)numberOfSides;
@end
Controller.h:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"
#import "PolygonView.h"
@interface Controller : NSObject {
IBOutlet UIButton *decreaseButton;
IBOutlet UIButton *increaseButton;
IBOutlet UILabel *numberOfSidesLabel;
IBOutlet PolygonShape *polygon;
IBOutlet PolygonView *polygonView;
}
- (IBAction)decrease;
- (IBAction)increase;
- (void)awakeFromNib;
- (void)updateInterface;
@end