Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton in UITableViewCell crashes when clicked
    primarykey
    data
    text
    <p>This should be simple, but I can't figure out what's wrong. I'm creating a tableview and I want a button that I can click to switch between checked and unchecked:</p> <pre><code> UITableViewCell *cell; cell = [tableView dequeueReusableCellWithIdentifier:DiaperCellIdentifier]; if (cell == nil) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DiaperCellIdentifier] autorelease]; wetButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; image = [UIImage imageNamed:@"unchecked_large.png"]; CGRect frame = CGRectMake(150.0, 5.0, image.size.width, image.size.height); wetButton.frame = frame; [wetButton setBackgroundImage:image forState:UIControlStateNormal]; [wetButton addTarget:self action:@selector(wetClicked:) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:wetButton]; </code></pre> <p>Now when I click this button, I get a stack trace....[NSCFString scale]: unrecognized selector sent to instance.... thanks for any help.</p> <pre><code>- (void) wetClicked:(id)sender{ if (isWet) { isWet = NO; [wetButton setBackgroundImage:@"unchecked_large.png" forState:UIControlStateNormal]; } else { isWet = YES; [wetButton setBackgroundImage:@"checked_large.png" forState:UIControlStateNormal]; } </code></pre> <p>}</p> <p>and here's the trace:</p> <p>2011-03-09 10:19:57.124 InfantCare[64064:207] -[NSCFString scale]: unrecognized selector sent to instance 0x33be0</p> <p>2011-03-09 10:19:57.240 InfantCare[64064:207] <em>*</em> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString scale]: unrecognized selector sent to instance 0x33be0'</p> <p><em>*</em> Call stack at first throw:</p> <p>(</p> <pre><code>0 CoreFoundation 0x00f2dbe9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x010825c2 objc_exception_throw + 47 2 CoreFoundation 0x00f2f6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 3 CoreFoundation 0x00e9f366 ___forwarding___ + 966 4 CoreFoundation 0x00e9ef22 _CF_forwarding_prep_0 + 50 5 UIKit 0x003d1e7b -[UIImageView setImage:] + 250 6 UIKit 0x004ea353 -[UIButton layoutSubviews] + 273 7 QuartzCore 0x01d58451 -[CALayer layoutSublayers] + 181 8 QuartzCore 0x01d5817c CALayerLayoutIfNeeded + 220 9 QuartzCore 0x01d5137c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310 10 QuartzCore 0x01d510d0 _ZN2CA11Transaction6commitEv + 292 11 QuartzCore 0x01d817d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99 12 CoreFoundation 0x00f0efbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27 13 CoreFoundation 0x00ea40e7 __CFRunLoopDoObservers + 295 14 CoreFoundation 0x00e6cbd7 __CFRunLoopRun + 1575 15 CoreFoundation 0x00e6c240 CFRunLoopRunSpecific + 208 16 CoreFoundation 0x00e6c161 CFRunLoopRunInMode + 97 17 GraphicsServices 0x017cf268 GSEventRunModal + 217 18 GraphicsServices 0x017cf32d GSEventRun + 115 19 UIKit 0x0031642e UIApplicationMain + 1160 20 InfantCare 0x00002228 main + 102 21 InfantCare 0x000021b9 start + 53 </code></pre> <p>)</p> <p>terminate called after throwing an instance of 'NSException'</p> <p>Program received signal: “SIGABRT”.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload