ios - How to send and get data between two view controller? -
i have 2 view controller in storyboard. vc1 has 3 buttons , vc2 has image view.
when click button in vc1, vc2 show image of a. when click button b in vc1, vc2 show image of b.
how vc2 can know button clicked in vc1?
this simple!!!
1) in vc2 create nsstring property in .h file , synthesize in .m file "nsstringobjofvc2" 2) import vc2 in vc1 .h file #import "vc2" , create object this
vc2 *vc2obj;
3) in viewdidload method
vc2obj = [[vc2 alloc] init];
4) on each button click add together this
vc2obj.nsstringobjofvc2 = @"differentimagenameforall3buttons.png";
last utilize image in vc2
simply utilize nsstringobjofvc2 in uiimage filename
ios xcode
No comments:
Post a Comment