Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to determine method error (Objective C/iPhone/xCode)?
    primarykey
    data
    text
    <p>While working through examples presented by Mark and LeMarche, I have encountered a number of situations where things don't work as expected. For example, Chapter 4 discusses 'Spiffing up a button' with an image. I can't seem to get an image stretched on the button, despite the fact that I followed the original instructions and a number of work arounds [1,2,3].</p> <p>How does one determine the error encountered in a Objective C method which returns void? (IMHO, a useless paradigm). Guessing at the culprit or error is a useless waste of time, and its not working well for me.</p> <p>Sorry about being snippy - I am at wits end, and I am tired of all the printf's, NSLogs, and guessing. This is no way to develop programs.</p> <p>Jeff</p> <hr> <p>[1] <a href="https://stackoverflow.com/questions/785986/resizing-an-image-with-stretchableimagewithleftcapwidth">Resizing an image with stretchableImageWithLeftCapWidth</a></p> <p>[2] <a href="https://stackoverflow.com/questions/1274433/stretchableimagewithleftcapwidthtopcapheight-doesnt-work-in-initwithcoder-of-u">stretchableImageWithLeftCapWidth:topCapHeight doesn&#39;t work in initWithCoder: of UIImageView subclass</a></p> <p>[3] <a href="https://stackoverflow.com/questions/2924408/iphone-stretchableimagewithleftcapwidth-only-makes-ds">iPhone stretchableImageWithLeftCapWidth only makes &quot;D&quot;s</a></p> <hr> <pre><code>// Source code from Mark and LeMarch ('Beginning iPhone 4 Programming', Chapter 4, pp. 99-100) // added for completeness. The same code is presented in 'Beginning iPhone 3 Programming'. // The button type is 'Custom', and the mode is 'Scale to Fill'. Trying to use TIFFs, // removing Alpha channels, resizing buttons so their size is image.height+1, etc - no joy. // The buttons were provided by Apple in their UICatalog example (http://developer.apple.com/library/ios/#samplecode/UICatalog/Introduction/Intro.html). // I've also tried to assign the image to a single button in case the resource cannot be shared. // Finally, no ASSERTs fire (and no exceptions are thrown), so all should be OK (yea, right). - (void)viewDidLoad { [super viewDidLoad]; UIImage* whiteButton = [UIImage imageNamed:@"whiteButton.png"]; ASSERT(whiteButton != nil); UIImage* strechableWhiteButton = [whiteButton stretchableImageWithLeftCapWidth:12.0 topCapHeight:0.0]; ASSERT(strechableWhiteButton != nil); [changeSrcFileButton setBackgroundImage:strechableWhiteButton forState:UIControlStateNormal]; [changeDestFileButton setBackgroundImage:strechableWhiteButton forState:UIControlStateNormal]; UIImage* blueButton = [UIImage imageNamed:@"blueButton.png"]; ASSERT(blueButton != nil); UIImage* strechableBlueButton = [blueButton stretchableImageWithLeftCapWidth:12 topCapHeight:0]; ASSERT(strechableBlueButton != nil); [changeSrcFileButton setBackgroundImage:strechableBlueButton forState:UIControlStateHighlighted]; [changeDestFileButton setBackgroundImage:strechableBlueButton forState:UIControlStateHighlighted]; } </code></pre>
    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.
 

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