Potrzebuję mieć dwa UITableViews na jednym UIView. mogę pracować z jednym, oto kod:Wiele UITableViews na jednym UIView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [contentOne count]; // sets row count to number of items in array
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
NSString *firstValue = [[NSString alloc] initWithFormat: @"Row %i% %", indexPath.row+1 ];
NSString *secondValue = [contentOne objectAtIndex:indexPath.row];
NSString *cellValue = [firstValue stringByAppendingString: secondValue]; // appends two strings
[cell.textLabel setText:cellValue];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
Próbowałem kilka różnych sposobów. Ktoś? Gdybym mógł nazwać każdy UITableView inną nazwą, która powinna to zrobić, ale nie pozwoli mi edytować tableView na nic innego bez awarii.
Duplikat Pytanie Spróbuj rozwiązanie podane w: http://stackoverflow.com/a/11789681/846372 – Soniya