Apple iPhone 3.0 SDK: Fixed bug on UIButton buttonWithType

As indicated in the post Apple iPhone SDK 3.0: first incompatibility of the Apple SDK 3.0 show different behaviors with respect to release 2.2.1. Support service for developers gave me the answer, and then the solution to the problem. . The answer was that the technical support [UIButton buttonWithType:] already called - inside - the initWithFrame . It follows that, according to the technical support, writing:

1
[ [ UIButton buttonWithType : UIButtonTypeRoundedRect ] initWithFrame : CGRectMake ( 0 , 0 , 100 , 40 ) ] ; UIButton * myButton = [[UIButton buttonWithType: UIButtonTypeRoundedRect] initWithFrame: CGRectMake (0, 0, 100, 40)];

It invokes initWithFrame twice, resulting in the loss of the label text. Basically just replace the code above with:

1
2
[ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; UIButton * myButton = [UIButton buttonWithType: UIButtonTypeRoundedRect];
0 , 0 , 100 , 40 ) ; myButton.frame CGRectMake = (0, 0, 100, 40);

The original response:

1
2
3
+ [UIButton buttonWithType:] Already calls initWithFrame: for you. Calling it twice Causes That Erases internal information you see the problem with the disappearing text. Changes in the Code Revealed 3.0 bug. In your code, just say:
UIButton restart_button * = [UIButton buttonWithType: UIButtonTypeRoundedRect];
restart_button.frame CGRectMake = (40,430,100,40);

There are no comments for this post

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL