【发布时间】:2014-03-26 17:47:49
【问题描述】:
//Objects list
//objects scroll
UIScrollView *objects;
objects=[[UIScrollView alloc]initWithFrame:CGRectMake(0,80,512,688)];
objects.showsVerticalScrollIndicator=YES;
objects.scrollEnabled=YES;
objects.userInteractionEnabled=YES;
objects.backgroundColor = [UIColor clearColor];
[self.view addSubview:objects];
[objects setUserInteractionEnabled:YES];
[objects setCanCancelContentTouches:YES];
objects.contentSize = CGSizeMake(512,689);
//divider
UIButton *divider = [UIButton buttonWithType:UIButtonTypeCustom];
[divider setBackgroundImage:[UIImage imageNamed:@"white.png"]forState:UIControlStateNormal];
divider.frame = CGRectMake(300, 0, 1, 768);
[divider setTitle:@"" forState:UIControlStateNormal];
[self.view addSubview:divider];
divider.adjustsImageWhenHighlighted = NO;
//array colors
UIImage *color[3000];
//color setup
color[0] = [UIImage imageNamed:@"item.png"];
UIImageView *originalImageView = [[UIImageView alloc] initWithImage:color[0]];
[originalImageView setFrame:CGRectMake(300, 0, 212, 62)];
[objects addSubview:originalImageView];
//array buttons
UIImageView *button[3000];
//button setup
button[0] = [[UIView alloc] initWithFrame:[originalImageView frame]];
UIImageView *maskImageView = [[UIImageView alloc] initWithImage:color[0]];
[maskImageView setFrame:[button[0] bounds]];
[[button[0] layer] setMask:[maskImageView layer]];
button[0].backgroundColor = [UIColor blueColor];
[objects addSubview:button[0]];
//add object button
UIButton *plus = [UIButton buttonWithType:UIButtonTypeCustom];
[plus setBackgroundImage:[UIImage imageNamed:@"plus.png"]forState:UIControlStateNormal];
plus.frame = CGRectMake(394, 106, 25, 25);
[plus setTitle:@"" forState:UIControlStateNormal];
[objects addSubview:plus];
plus.adjustsImageWhenHighlighted = YES;
-(void)viewDidLoad {
[super viewDidLoad];
UIButton *add = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[add addTarget:self action:@selector(aMethod:)forControlEvents:UIControlEventTouchDown];
[add setTitle:@"add new" forState:UIControlStateNormal];
add.frame = CGRectMake(100, 100, 100, 100);
[self.view addSubview:add];
}
- (void) aMethod:(id)sender {
button[0].backgroundColor = [UIColor greenColor];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
这是更新后的代码,一些是之前的,而所有的都是之后的。该程序还有很多其他功能,但它只是为 GUI 设置不同的视觉元素。错误标记在 sais.. 的行上。
-(void)viewDidLoad {
错误是这样的..
Use of undeclared identifier 'viewDidLoad'
您想了解更多信息吗?
【问题讨论】:
-
这是在哪个班级? viewDidLoad 是 UIViewController 上的一个方法,所以你的类需要是 UIViewController 的一个实例或一个的子类。我认为您的问题没有提供足够的信息。
-
如果能回答你的问题,它就在 viewcontroller.m 文件中
-
@AndrewSavage,Dave 在您的 viewcontroller.h
@interface ViewController : UIViewController中谈到了继承 -
哦,这就是我的 .h 文件中的内容
-
发布完整的错误消息和错误周围的代码,包括前面的行。很可能您缺少分号或其他内容
标签: ios methods viewdidload