user1058043
user1058043

Reputation: 71

IPhone: create view with text and images

I want create some view, and add dynamically to it text and images Somebody knows how I can to do it?

Thanks

Upvotes: 0

Views: 161

Answers (1)

Tim
Tim

Reputation: 14446

Broad question, but this should get you on the right path: (Pop this into a viewcontroller)

-(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];
}

Then, bind this method to your UIButton's touchUpInside event using Interface Builder.

Upvotes: 1

Related Questions