1

I have a UIView, and I want to add an another UIView as a subView to it.

This is what I have done:

- (IBAction)showVerification:(id)sender { [self.viewM addSubview: self.verificationView]; [self.labelVerification setText:offerId]; } 

And this is the result:

enter image description here

Can You help me? Is it impossible to add a UIView to another in .xib file?

4
  • I think you'll have to be a bit more specific about what you want to happen. Also, can you explain what is wrong with the result you are getting. Commented Oct 16, 2012 at 12:14
  • what is the result you wold like to have? Commented Oct 16, 2012 at 12:14
  • I'll add the image at the end of my question. Commented Oct 16, 2012 at 12:15
  • @Fogmeister, it should not fill all the screen. Just look at my first image. I selected the UIView in the right side. It should be fit for that size. Commented Oct 16, 2012 at 12:18

3 Answers 3

1

You can do it programmatically :

UIView* view2 = [[UIView alloc]initWithFrame:CGRectMake(30, 100, 1024-30, 768-110)]; [self.view addSubView:view2]; 
Sign up to request clarification or add additional context in comments.

3 Comments

What is the problem to add it in .xib file? Is it impossible? and why?
i think programmatically is easier
just he constains or autolaout make this result you have to remove those constrains form uiview and all will be settled :)
1

See my images i have done same and nothing is moved in it

Two views

Image 1

After combining them just drag and drop it in side the view

Image 2

And in Simulator

Image 3

5 Comments

Take a look at the right photo again. Can you see the background image on it. how can I set that Image? Ofcourse I have UIView and then I add an ImageView to it, and then I add the final UIView, as shown in my right picture.
And now I want to add the new UIView to the final UIView.
I appreciate for your complete answer. +1 until now.
And the point is, I don't want to drag and drop it. It is not as easy as that, As you see my code, I want to do that programmatically via AddSubView.
you can also do this by coding as @Jossef has instructed just create the view with desired property and size and add it to view :)
0

You can do as Wolvorin suggested or set an outlet for that leftview then add it into view on button event

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.