In RootViewController I have a button *flop1 that when clicked opens PopViewController through segue *segPop and when a selection is chosen and the popover closes, button *flop1 's image is changed.
我希望有多个按钮,例如 *flop1,每个按钮都可以由自己选择的图像填充,同时使用相同的 PopViewController。
我已经通过 seque *segPop2 将 *flop2 连接到同一个 PopViewController。
根视图控制器.m
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"segPop"]) {
currentPopoverSegue = (UIStoryboardPopoverSegue *)segue;
pvc = [segue destinationViewController];
[pvc setDelegate:self];
[pvc setStrPassedValue:[tfUserText text]];
} else if ([[segue identifier] isEqualToString:@"segPop2"]) {
currentPopoverSegue = (UIStoryboardPopoverSegue *)segue;
pvc = [segue destinationViewController];
[pvc setDelegate:self];
[pvc setStrPassedValue:[tfUserText text]];
}
}
// PopViewControllerDelegate callback function
- (void)dismissPop:(NSString *)value {
NSString *imagefile;
imagefile = [NSString stringWithFormat:@"%@.png",value];
[flop1 setImage:[UIImage imageNamed:imagefile] forState:UIControlStateNormal];
[[currentPopoverSegue popoverController] dismissPopoverAnimated: YES]; // dismiss the popover
}
@end
如何在我的
- (void)dismissPop:(NSString *)value {
用新图像填充 *flop2 按钮,同时保持 *flop1 图像不变?
如果这一切看起来很混乱,我很抱歉,我的编程教育为零,并且正在通过模仿来尝试所有这些。
谢谢