Tuesday, 15 July 2014

objective c - Create A New iOS Control -



objective c - Create A New iOS Control -

i trying create new command xcode implement new ios app. end thought display formation of football game squad graphically. realise coded programmatically want create new command represent player , load formation accordingly may add together other player info command in future.

i have created xib view file, in label displaying name. have tried next label's text doesn't show up. missing obvious?

[i have included right headers , have connected label , set xib new class]

header file xib:

@interface playerobject : uicontrol @property (nonatomic, strong) nsstring *playernamelabel; @end

implementation file xib:

#import "playerobject.h" @interface playerobject () @property (strong, nonatomic) iboutlet uilabel *namelabel; @end @implementation playerobject - (void) setplayernamelabel:(nsstring *)playernamelabel { self.namelabel.text = playernamelabel; }

view controller implementation file:

- (void)viewdidload { ... playerobject *newplayer = [[playerobject alloc] initwithframe:cgrectmake(10, 10, 100, 150)]; [newplayer setplayernamelabel:@"test"]; [newplayer setbackgroundcolor:[uicolor redcolor]]; [self.view addsubview:newplayer]; }

thanks in advance!

you may have created xib file containing label not appear using it. creating new instance of playerobject class instead of loading 1 xib file. take @ uinib class documentation instead.

ios objective-c uicontrol

No comments:

Post a Comment