【发布时间】:2016-10-10 07:34:54
【问题描述】:
我有一个循环,我在其中创建带有调用 prepareForSegue 的选择器的按钮。我会将我单击的按钮的图像传递到下一页。
for (i = 1; i <= 22; i++) //22 it's just temporary
{
//creating button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(nextPage: )
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"" forState:UIControlStateNormal];
button.frame = CGRectMake(X, Y, 100.0, 100.0);
UIImage *buttonImageNormal = [UIImage imageNamed:@"ambient.png"];
//image obviously will be different and i want to pass that
[button setBackgroundImage:buttonImageNormal forState:UIControlStateNormal];
if (i%3==0 && i==0)
X = 20;
if (i%3==0 && i!=0){
X = 20;
Y = Y+150;
}
if (i%3==1)
X = 140;
if (i%3==2)
X = 260;
[_scroll addSubview:button];
}
这是每个按钮调用的方法
-(void)nextPage:(id)sender {
UIViewController *myController = [self.storyboard instantiateViewControllerWithIdentifier:@"signSegue"];
[self.navigationController pushViewController: myController animated:YES];
}
这就是prepareForSegue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
addController *controller = (addController *)segue.destinationViewController;
}
我必须通过控制器传递什么?
【问题讨论】:
标签: objective-c