Я разрабатываю приложение для бронирования билетов в театр.В этом я хочу отобразить расположение мест, чтобы пользователь мог выбрать количество мест, которые он хочет.поэтому я планировал отображать его по строкам и столбцам внутри табличного представления.Это предложено?Или какие-то другие решения есть?Вот мой код для отображения кнопок в представлении UIScroll.Как я могу двигаться дальше.Также мне нужно обрабатывать события нажатия для этих кнопок, получать информацию и обрабатывать ее позже.Мне тоже нужны некоторые идеи ... Пожалуйста, предложите мне несколько образцов.
- (Void) someMethod {
int x = 20, y = 15, rows = [rowsArr count];
for (int i = 0; i < [rowsArr count]; i++) {
NSDictionary * rowsDict = [rowsArr objectAtIndex:i];
NSArray * seatsarr = [rowsDict valueForKey:@"Seats"];
if (![[rowsDict valueForKey:@"RowDescription"] isEqualToString:@"Way"])
[self chapterCreationwithtitle:[NSString stringWithFormat:@"%@", [rowsDict valueForKey:@"RowDescription"]]
withChapterTag:tag + i
andXvalue:x andYvalue:y];
y = y + thumb_incrementY;
if (i == rows) { // (main_scroll.frame.size.width-thumb_incrementX))
x = x + thumb_incrementY;
x = 40;
index1++;
rows = (rows + [rowsArr count]);
}
strSeatDes = [[NSMutableArray alloc] init];
int seats = [seatsarr count];
for (int j = 1; j <= [seatsarr count]; j++) {
NSLog(@"index %d", index2);
NSDictionary * seatsDict = (NSDictionary *)[seatsarr objectAtIndex:j - 1];
[strSeatDes addObject:[NSString stringWithFormat:@"%@", [seatsDict valueForKey:@"SeatDescription"]]];
if (![[seatsDict valueForKey:@"isPassage"] boolValue])
[self seatsCreationwithtitle:[NSString stringWithFormat:@"%@", [seatsDict valueForKey:@"SeatDescription"]] withSeatsTag:tag2 + j andXvalue:xx andYvalue:yy];
xx = xx + thumb_incrementX;
NSLog(@"tag seat:%d", tag2 + j);
if (j == seats) {
yy = yy + thumb_incrementY;
xx = 80;
index2++;
tag2 = tag2 + 100;
seats = (seats + [seatsarr count]);
}
}
NSLog(@"%d", [strSeatDes count]);
main_scroll.contentSize = CGSizeMake(([seatsarr count] + 2) * thumb_incrementX + 110, ([rowsArr count] + 2) * thumb_incrementY);
}
} /* someMethod */
- (void) chapterCreationwithtitle:(NSString *)title withChapterTag:(NSInteger)tags andXvalue:(NSInteger)x andYvalue:(NSInteger)y {
chapter_button = [UIButton buttonWithType:UIButtonTypeCustom];
chapter_button.frame = CGRectMake(x, y, button_width, button_height);
chapter_button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[chapter_button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[chapter_button setTitle:title forState:UIControlStateNormal];
chapter_button.titleLabel.font = [UIFont boldSystemFontOfSize:16];
[chapter_button setShowsTouchWhenHighlighted:YES];
[chapter_button setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin];
[chapter_button setBackgroundColor:[UIColor darkGrayColor]];
[chapter_button setTag:tags];
// [chapter_button addTarget:self action:NSSelectorFromString(@"getAction:") forControlEvents:UIControlEventTouchUpInside];
[self.main_scroll addSubview:chapter_button];
}
- (void) seatsCreationwithtitle:(NSString *)title withSeatsTag:(NSInteger)tags andXvalue:(NSInteger)x andYvalue:(NSInteger)y {
seats_button = [UIButton buttonWithType:UIButtonTypeCustom];
seats_button.frame = CGRectMake(x, y, button_width, button_height);
seats_button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[seats_button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[seats_button setTitle:title forState:UIControlStateNormal];
seats_button.titleLabel.font = [UIFont boldSystemFontOfSize:16];
[seats_button setShowsTouchWhenHighlighted:YES];
[seats_button setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin];
[seats_button setBackgroundColor:[UIColor colorWithRed:0.09375 green:0.09765 blue:0.02734 alpha:0.4]];
[seats_button setTag:tags];
[seats_button addTarget:self action:NSSelectorFromString(@"getAction:") forControlEvents:UIControlEventTouchUpInside];
// main_scroll.contentSize = CGSizeMake(x+50, y+50);
[self.main_scroll addSubview:seats_button];
}