我正在尝试将NSDictionary从UIViewcontroller转移到UIView
字典包含多边形的x和y值
Uiview将绘制此多边形
我的问题是UIViewcontroller上存在x y值,
它们到达Uiview的initWithFrame,
但无法在Uiview中达到drawRect
请帮我。
#import "ViewController.h"
#import "circles_3.h"
#import "draw.h"
@implementation ViewController
@synthesize Core;
- (void)viewDidLoad
{
[super viewDidLoad];
int i;
// Returns NSMutable dictionary with x y points of polygons, some nsstrings and some colors
circles_3 *geo = [circles_3 alloc];
self.Core=[geo updatenum:self.Core];
// Count number of Patches
NSUInteger numObjects = [[self.Core valueForKeyPath:@"Data"] count];
NSArray* filtered=[Core objectForKey:@"Data"];
// Pointer to the UIview class
draw *patch;
// Iterate for all the polygons
for (i=0;i<numObjects;i++)
{
NSDictionary *data = [filtered objectAtIndex:i];
// Sent the data to the draw class for plotting
patch = [[draw alloc] initWithFrame:[[UIScreen mainScreen] bounds] data :data];
[self.view addSubview:patch];
}
}
@end
#import <UIKit/UIKit.h>
#import "ViewController.h"
#define ARC4RANDOM_MAX 0x100000000
@interface draw : UIView
@property NSDictionary * data;
- (id)initWithFrame:(CGRect)frame data:(NSDictionary *)Core;
@end
UIview类
#import "draw.h"
@implementation draw
@synthesize data;
- (id)initWithFrame:(CGRect)frame data:(NSDictionary *)Core;
{
self = [super initWithFrame:frame];
if (self)
{
self.data=Core;
}
return self;
}
- (void)drawRect:(CGRect)rect
{
// In here i get nil for
self.data
???????????????
}