开发者

how update one xib label from another class

开发者 https://www.devze.com 2023-01-15 00:52 出处:网络
I want that update in player controller song duration of song(which is downloaded from the server) from the playlist controller.

I want that update in player controller song duration of song(which is downloaded from the server) from the playlist controller.

Actually i m us开发者_Go百科ing avaudioplayer so in player i have two controller avtouchcontroller and avtouchview controller,and one xib of avtouchviewcontroller where all things (play pause next prev song duration).

so in avtouch controller i have a method UpdatePlayerInfo if i call this function then my problem is solved.

How i call updateplayerinfo(which is in avtouchcontroller) function from other(avtouchviewcontroller).


You should create instance variable UILabel *someLabel; in target class and add IBOutlet property to it. (or just IBOutlet UILabel *someLabel;).
Next step is to make relation (in IB) between displayed label and outlet.
Step 3. Profit (manage instance variable as you wish).


take a iboutlet label in .h file and bind it with your xib file set the property of that label in .h file and synthesis that label in .m file.

Then in the class from where you want to change the label text set it using the object of the above class

EDIT: ADDED EXAMPLE EG: In classA you have the label in XIB then in CLASSA.h take iboutlet uilabel labelA set its property synthesize it and bind this with the label in XIB. Then goto CLASSB take objct of class A and objClassA.labelA=@"CHAANGEDVALUE"

ClassA.h
UILabel *myLabel;

@property(nonatomic,retain)IBOutlet UILabel *myLabel;

.

ClassA.m
@synthesis mylabel.

NOW go to XIB file and in files owner inspector you will find mylabel BIND it with your label in xib.

ClassB.m//Accesing label in Another Class
ClassA objClassA;//ALOCATE THE INSTANCE
objClassA.myLabel=@"NEWVALUE";

hAPPY cODING...

0

精彩评论

暂无评论...
验证码 换一张
取 消