我想创建一些视图,并动态添加文本和图像 有人知道我该怎么做吗?
由于
答案 0 :(得分:1)
广泛的问题,但这应该让你走上正确的道路:(将其弹出到视图控制器中)
-(void)addStuffToView{
UIView* myView = [self view]; // get the view controller's view
UIImageView* myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,100,100)];
[myImageView setImage:[UIImage imageNamed:@"imagefile.jpg"]];
[myView addSubview:myImageView];
[myImageView release];
UILabel* myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,100,100,50)];
myLabel.text = @"Some text here";
[myView addSubview:myLabel];
[myLabel release];
}
然后,使用Interface Builder将此方法绑定到您的UIButton的touchUpInside
事件。