我有一个MainClass.m,其中包含scrollView和UIView的UI,然后我有一个不同的类来实现scrollView。
我的scrollView中有一个RadioButton,单击它时,我需要将selectedValue传递给MainClass.m,它具有一个“ Continue”按钮,并应检索该继续按钮的onClick。
这是我的代码:
- (void)radioButtonTapped:(UIButton*)sender{
if (self.radioBtn.isSelected == true) {
[self.radioBtn setSelected:NO];
self.productValue = [[ViewController2 sharedInstance] stringValue:self.productId];
[self.radioBtn setImage:[UIImage imageNamed:@"radio-button"] forState:UIControlStateNormal];
}else {
[self.radioBtn setSelected:YES];
self.productValue = [[ViewController2 sharedInstance] stringValue:self.productId];
[self.radioBtn setImage:[UIImage imageNamed:@"radio-button-select"] forState:UIControlStateNormal];
}
}
//This method is in viewController2
- (NSString*) stringValue:(NSString *) productValue{
self.strVal= productValue;//I get the value here
return productValue;
}
//This method is in viewController2
- (IBAction)productCellBtnAction:(UIButton*)sender {
NSLog(@"strVal :%@",self.strVal);
//I get self.strVal = null
}