I create an UIView in applicationDidFinishLaunchingWithOptions method:
CGRect inputTextViewRect = CGRectMake(0, 420, 320, 80);
UIView *inputTextView = [[UIView alloc] initWithFrame:inputTextViewRect];
inputTextView.backgroundColor = [UIColor grayColor];
Then I create two subviews – one UIButton and one UITextView:
UITextView *inputTextField = [[UITextView alloc] initWithFrame:CGRectMake(10, 450, 230, 20)];
UIButton *sendButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
CGRect buttonFrame = CGRectMake(250, 450, 50, 20);
My problem is if I add my inputTextField and sendButton as subviews to main window – they will be visible and working. If I add them to my UIView:
[inputTextView addSubview:inputTextField];
[inputTextView addSubview:sendButton];
And then add this view to main window:
[self.window addSubview:inputTextView];
In this case i see only gray background of inputTextView and no subviews that were added before.
Could you please help me figure out whats wrong with it?
The problem is with your
CGRectMakecall:x and y and are coordinates where you want to place the element over the super view, so you have the following, which is incorrect:
Try changing those to
After changing this you will be able to see UITextView and UIButton, then you make the x and y position changes according to your need.