• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Adding subviews to UITableViewCell's contentView and autoresizing behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding subviews to UITableViewCell's contentView and autoresizing behavior


  • Subject: Re: Adding subviews to UITableViewCell's contentView and autoresizing behavior
  • From: Luke Hiesterman <email@hidden>
  • Date: Thu, 03 Mar 2011 20:37:02 -0800

Flexible width means "change my width if my superview's width changes" and accessory views cause the contentView to shrink from its original state as the full width of the cell (since the contentView must make space for the accessoryView). Therefore, your subview auto shrinks with it since you set the mask. Make sense?

Luke

On Mar 2, 2011, at 10:39 PM, Ray <email@hidden> wrote:

> Hi! First post to the list, please be gentle ;)
>
> Small question: when I add a subview to the contentView of a UITableViewCell, the rendered width of the subview's frame will be different, depending on whether I set the autoresizingMask in combination with an accessoryView. So, when I set up a clean test project using the usual UITableViewController, make its TableView visible etc. and then use this example code:
>
> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
>
>  static NSString *CellIdentifier = @"Cell";
>  UIView *testView;
>  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
>  if (cell == nil) {
>      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
>
>        testView = [[[UIView alloc] initWithFrame:CGRectMake(10.0, 10.0, 226.0, 12.0)] autorelease];
>        // testView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
>        testView.backgroundColor = [UIColor redColor];
>        [cell.contentView addSubview:testView];
>
>        UIView *testHolder = [[[UIView alloc] initWithFrame:CGRectIntegral(CGRectMake(0.0, 0.0, 64.0, 32.0))] autorelease];
>        testHolder.backgroundColor = [UIColor greenColor];
>        cell.accessoryView = testHolder;
>  }
>
>  return cell;
> }
>
> the actual rendered width of the testView will be smaller (in this case 70 points I think it was) when I uncomment the UIViewAutoresizingFlexibleWidth bit. There will be no difference when I don't use a cell.accessoryView...
>
> Is this expected behavior? Does it have to do with how the cell layouts its subviews depending on the use of an accessoryView? I couldn't find this in the documentation nor the list archive, so if anyone could enlighten me, much appreciated! I would also be interested in workarounds...
>
> Thanks!
> - Ray.
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Adding subviews to UITableViewCell's contentView and autoresizing behavior (From: Ray <email@hidden>)

  • Prev by Date: Re: NSXMLElement children doesn't return whitespace text nodes
  • Next by Date: Re: NSTableView: which delegate after a drag operation?
  • Previous by thread: Adding subviews to UITableViewCell's contentView and autoresizing behavior
  • Next by thread: Re: Adding subviews to UITableViewCell's contentView and autoresizing behavior
  • Index(es):
    • Date
    • Thread