> Date: Fri, 11 Nov 2011 20:38:29 +0000 > From: Luke Hiesterman <luket...@apple.com> > Subject: Re: -tableView:accessoryButtonTappedForRowWithIndexPath: > Sometimes returns wrong indexPath.row > To: "Michal L. Wright" <m...@raccoonbend.com> > Cc: "<cocoa-dev@lists.apple.com>" <cocoa-dev@lists.apple.com> > Message-ID: <806feb2b-6c18-4768-9d14-f1c538e46...@apple.com> > Content-Type: text/plain; charset="us-ascii" > > > On Nov 11, 2011, at 12:35 PM, Michal L. Wright wrote: > >> Hi, >> >> I have a UITableView that has four sections. Sections 0 and 2 have a single >> row each. Sections 1 and 3 have variable numbers of rows. >> >> Each row in sections 1 and 3 has an accessory view set up by the following >> lines in -tableView:cellForRowAtIndexPath: >> >> UITableViewCell cell; >> cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; >> >> Most of the time, tableView:accessoryButtonTappedForRowWithIndexPath: >> returns the correct value for indexPath.row, but occasionally it returns the >> next row. When the problem occurs with the last row, it seems to return an >> invalid value. >> >> One of the odd things about this problem is that the rows for which >> incorrect values are returned vary with the point size of the label.text. >> >> tableView:heightForRowAtIndexPath: returns the following value, where >> mw_fontSize is an NSString for the point size of the label.text: >> >> CGFloat rowHeight; >> rowHeight = [mw_fontSize floatValue] * 2; >> >> I've tried 2.2 and 2.4 for the multiplier. That changes which rows have the >> problem for any given point size, but with 7 to 10 rows in a section, and >> fontSize ranging from 12 to 24, in a variety of fonts, from American >> Typewriter to Zapfino, I have not found a fontSize-multiplier combination >> that does not have at least one row showing the problem. (Actually, the >> font, itself, seems to be irrelevant.) >> >> The rows all show the correct text, and all behave correctly when tapped >> outside the accessory button. In the Simulator, it's very easy to see the >> button darken when pressed, so it's quite clear that the wrong value is >> being returned by tableView:accessoryButtonTappedForRowWithIndexPath:. >> >> The problem occurs with iOS 4.3 and iOS 5.0 simulators for the iPad and >> iPhone, and with my iPhone 3G running iOS 4.2.1. >> >> A Google search found one person complaining about the same problem, which >> was not resolved, >> >> So, my questions are: >> >> 1. Is this likely to be an iOS bug that I should report? > > Certainly sounds like a bug from your description. It never hurts to file, > and bugs don't get fixed without bug reports. > > Luke > >> >> 2. If not, what am I doing wrong? >> >> 3. If so, does anyone know of a workaround? >> >> Thanks, >> -- Mike Wright
Thanks, Luke. I've filed Bug ID# 10442618. It turns out that indexPath.section can also be incorrect -- apparently only when indexPath.row is 0. This also varies with the cell rowHeight and/or font size. -- Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com