Apple iPhone 3.0 SDK: Korrektur eines Fehlers auf UIButton buttonWithType

Wie im Beitrag angegeben Apple iPhone SDK 3.0: Erste Inkompatibilität des Apple SDK 3.0 zeigen unterschiedliche Verhaltensweisen in Bezug auf 2.2.1 Release. Support-Service für Entwickler gab mir die Antwort, und dann die Lösung des Problems. . Die Antwort war, dass die technische Unterstützung [UIButton buttonWithType:] bereits genannt - im Inneren - die initWithFrame . Daraus folgt, dass nach der technischen Unterstützung, schreiben:

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

Es ruft initWithFrame zweimal, was den Verlust der Label-Text. Grundsätzlich ersetzen Sie einfach den obigen Code mit:

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

Die ursprüngliche Antwort:

1
2
3
+ [UIButton buttonWithType:] Schon ruft initWithFrame: für Sie. Aufruf zweimal Ursachen Das Löscht internen Informationen, die Sie das Problem mit dem Verschwinden Text zu sehen. Änderungen im Code Revealed 3,0 bug. In Ihrem Code, sagen Sie einfach:
UIButton restart_button * = [UIButton buttonWithType: UIButtonTypeRoundedRect];
restart_button.frame CGRectMake = (40,430,100,40);

Es gibt keine Kommentare für diesen Beitrag

Hinterlasse einen Kommentar

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