objective c - iOS: UIButton doesn't show up -
objective c - iOS: UIButton doesn't show up -
i'm creating simple button , adding subview main view. doesn't show though.
this code setting up:
uibutton* contactbutton = [[uibutton alloc] init]; contactbutton.titlelabel.text = @"contact developer"; [contactbutton sizetofit]; [self.view addsubview:contactbutton]; nslog(@"x: %f || y: %f || width: %f || height: %f", contactbutton.frame.origin.x, contactbutton.frame.origin.y, contactbutton.frame.size.width, contactbutton.frame.size.height);
as may have noticed, placed bit of debug code @ end see position , dimensions of button. are: x: 0, y: 0, width: 30, height: 34
this means should showing in upper left corner doesn't. whats wrong?
one possible reason used titlelabel
directly. consider using settitle:forstate:
method instead.
to sure, consider setting backgroundcolor
, debug step, create sure it's appearing.
edit others suggested, seek using buttonwithtype:
instead of [[uibutton alloc] init]
. suggest using uibuttontypesystem
instead of uibuttontypecustom
.
ios objective-c cocoa-touch uiview uibutton
Comments
Post a Comment