UIView not resizing in code or interface builder

I am creating a simple UIView and adding it to my main view - I am also changing the frame however no matter what I try it doesn't resize the view - it just lumps this huge view down onto my superview. Changing the view size in interface builder has no effect either:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view 
                      calloutAccessoryControlTapped:(UIControl *)control
{
    HotelInformationViewController *vc = 
    [[HotelInformationViewController alloc]initWithNibName:@"HotelInformationViewController" 
    bundle:nil control:control];

    [self.view addSubview:vc.view];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil control:(UIControl *)control
{
  if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) 
  {
    self.view.bounds = CGRectMake(control.frame.origin.x, control.frame.origin.y, 286, 286); //This is the size I want to view to be 286, 286 
  }
  return self;
}

Answers


You should be calling self.view.frame = CGRectMake(...). frame is the property that represents position and size of the view within its superview, and is the thing you change to move or resize a view.

(The bounds attribute is the internal boundaries of the view's coordinate system that the frames of the view's subviews exist within, and it's rarely if ever necessary to explicitly set it)


the problem is that you are trying to change the bounds, and you are supposed to change the frame. Bounds is rect in internal view that should be projected to the rect in superview - a frame. Imagine picture of size 300x300. If you have a view on the screen with frame (0,0,100,100) and you want to show the central part of that picture you should set bounds to (150,150, 100,100). As a result you will see the central part of you picture (without resizing) shown in a rect with size 100x100 in upper left corner of a superview.


Need Your Help

Index by version instead of node with Apache Solr in Drupal

php mysql drupal drupal-6 solr

I need to index not by nodes, but by each revision of the node in Apache Solr. Do I use hook_apachesolr_modify_query, hook_apachesolr_update_index, or neither? Has anyone done this?

How to select object at index in WP7?

windows arrays windows-phone-7 indexing

I have an array that has specified colors like this,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.