0
votes

I have created a view with buttons to collect feedback that I want to reuse in many places in my application. It is suppose to slide up from the bottom.

This is what I have done:

  1. Created the FeedbackView.xib
  2. Setting the file's owner as the FeedbackView
  3. In FeedbackView.h I have created an outlet contentsView to the root view in the .xib file
  4. I write the following in the Feedback.m file: -(void)awakeFromNib {[[NSBundle mainBundle] loadNibNamed:@"FeedbackView" owner:self options:nil];[self addSubview: self.contentsView];}
  5. In a view controller i drag in a view, and set the custom class to the FeedbackView
  6. Finally I create an outlet from the controller to the FeedbackView, called feedBackView

Now I try to move feedbackView with the setFrame or setCenter methods, but my actual view in the .xib file is not moving with. However I can move the feedbackView.contentsView, but then the buttons stop working.

What I really would like to do is having the feedbackView in the view controller hugging on to the contents in the .xib file and just moving it, and the subview contentsView will move with.

1

1 Answers

0
votes

I found out that the problem was that I had autolayout on. I turned it off and everything is now working smoothly. For the having the feedbackView hugging on to its contents I tried the [self.feedbackView sizeToFit]; which supposedly should fit the superview around its contents. However this is not working, if the FeedbackView.xib is 50 in height, and feedbackView is 100 calling the method will not change anything.