Имеется вот такой вот кусок кода. Программа создает 1000 кнопок которые отображены на scrollView. У каждой кнопки есть свой тег, который отображается на ней. Задача сделать так, чтобы по нажатию на любую из кнопок можно было перейти на другой viewController и на нем отображался порядковый номер этой кнопки. Спасибо!
@implementation RWTViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
_mainScroll.showsVerticalScrollIndicator = YES;
_mainScroll.scrollEnabled = YES;
_mainScroll.userInteractionEnabled = YES;
[self.view addSubview: _mainScroll];
_mainScroll.contentSize = CGSizeMake(320, 12520);
CGFloat x=0;
CGFloat y=0;
for (int i=0; i < 250; i++) {
for (int k=0; k< 4; k++) {
UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button.frame = CGRectMake(x, y,80, 50);
self.view.backgroundColor = [UIColor whiteColor];
button.backgroundColor = [UIColor redColor];
button.tag = i*4+k;
[button setTitle:[NSString stringWithFormat:@"%i", button.tag] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
[self.mainScroll addSubview: button];
x = x+80;
}
x = 0;
y = y+50;
}