在xcode中如何用代码添加多个按钮??
xcode吧
全部回复
仅看楼主
level 2
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 486, 40, 40) ];
[self.view addSubview:imageView];
imageView.image = [UIImage imageNamed:@"shiguang"];
imageView.userInteractionEnabled = YES;
UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
[imageView addSubview:btn];
[btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
}
一个的这样添加,那添加多个呢?怎么写??我是新手小白,求大神指点。。。
2015年11月06日 01点11分 1
level 9
循环
2015年11月06日 05点11分 2
谢谢~~我已经解决了~~
2015年11月07日 01点11分
level 2
楼上正解。循环。记得加上tag值区分
2015年11月06日 09点11分 3
[哈哈]谢谢~~
2015年11月07日 01点11分
1