• 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
Calculating row heights for view-based table rows, on re-use throws error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calculating row heights for view-based table rows, on re-use throws error


  • Subject: Calculating row heights for view-based table rows, on re-use throws error
  • From: Erik Stainsby <email@hidden>
  • Date: Fri, 17 Aug 2012 19:15:08 -0700

Hello all,

I have a view-based table in which there are four distinct row types, representing distinct object types which may appear. The tableRowViews are in the nib and represented in the code here as xxxCellView entities.


- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {

	id obj = [_content objectAtIndex:row];

	if([obj isKindOfClass:[RSPostalAddress class]]) {
		return self.postalCellView.bounds.size.height;
	}
	else if([obj isKindOfClass: [RSEmailAddress class]]) {
		return self.emailCellView.bounds.size.height;
	}
	else if([obj isKindOfClass: [RSPhoneNumber class]]) {
		return self.phoneCellView.bounds.size.height;
	}
	else {	// note field
		return self.notesCellView.bounds.size.height;
	}
}


My problem is that on first pass, this code returns quite sane and reasonable results: the manually set sizes of the prototype tableRowViews.  However on second pass, it goes insane: 132.0 becomes 266.0, 28.0 becomes 118.0, 104.0 becomes 210.0 ...  And the next thing the -tableView:heightOfRow: does is throw it's brain in the air and gives up …. :P


2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController tableView:heightOfRow:]- [0136] self.postalCellView.bounds.size.height: 266.000000
2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController tableView:heightOfRow:]- [0136] self.postalCellView.bounds.size.height: 266.000000
2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController tableView:heightOfRow:]- [0140] self.emailCellView.bounds.size.height: 118.000000
2012-08-17 18:51:52.766 RSSuperContactsX[24075:303] -[RSTableController tableView:heightOfRow:]- [0140] self.emailCellView.bounds.size.height: 118.000000
2012-08-17 18:51:52.767 RSSuperContactsX[24075:303] -[RSTableController tableView:heightOfRow:]- [0144] self.phoneCellView.bounds.size.height: 118.000000
2012-08-17 18:51:52.767 RSSuperContactsX[24075:303] -[RSTableController tableView:heightOfRow:]- [0148] self.notesCellView.bounds.size.height: 210.000000
2012-08-17 18:51:52.767 RSSuperContactsX[24075:303] *** -[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 5]
2012-08-17 18:51:52.769 RSSuperContactsX[24075:303] (
	0   CoreFoundation                      0x00007fff900a8716 __exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff8ad98470 objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff900455dc -[__NSArrayM objectAtIndex:] + 252
	3   RSSuperContactsX                    0x00000001000030f5 -[RSTableController tableView:heightOfRow:] + 101
	4   AppKit                              0x00007fff8a2e3322 -[NSTableView _sendDelegateHeightOfRow:] + 130
	5   AppKit                              0x00007fff8a2e30db -[NSTableView _uncachedRectHeightOfRow:] + 197
	6   AppKit                              0x00007fff8a2e2f7a -[_NSTableRowHeightStorage _cacheRowHeights] + 241
	7   AppKit                              0x00007fff8a29d6f5 -[_NSTableRowHeightStorage _ensureRowHeights] + 80
	8   AppKit                              0x00007fff8a2e3469 -[_NSTableRowHeightStorage copyWithZone:] + 89
	9   AppKit                              0x00007fff8a2e03eb -[NSTableRowData _saveCurrentRowHeightState] + 293
	10  AppKit                              0x00007fff8a2e0282 -[NSTableRowData beginUpdates] + 93
	11  AppKit                              0x00007fff8a29be0b -[NSTableView _beginUpdate] + 63
	12  AppKit                              0x00007fff8a2b473d -[NSTableView reloadData] + 33
	13  RSSuperContactsX                    0x0000000100003016 -[RSTableController setPerson:] + 2982
	14  RSSuperContactsX                    0x000000010000240b -[RSTableController setActivePerson:] + 779





My expectation is that I ought to be able to clear the table (iterating through the rows and applying -removeRowsAtIndexes:withAnimation:  to discard the present rowViews, and start clean with the next record to be displayed, generating new rowViews as needed (because the number of component elements (phone numbers/email addresses/etc) will vary from one record to the next).

I have no iterator code running at the time this error occurs, so I suspect I have failed to correctly setup some aspect of the tableView/rowView mechanics.  Does anything suggest itself to anyone ?

Hopefully,
Erik




_______________________________________________

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


  • Follow-Ups:
    • Re: Calculating row heights for view-based table rows, on re-use throws error
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: CGXDisableUpdate?
  • Next by Date: stripped down webview
  • Previous by thread: Re: CGXDisableUpdate?
  • Next by thread: Re: Calculating row heights for view-based table rows, on re-use throws error
  • Index(es):
    • Date
    • Thread