如何在我的UITableViewCell
中創建未知行數和列數的table
?我正在創建一個調查應用程序,報告也可以包含矩陣類型的問題。我如何查看我的TableViewCell中的那些。如果行數和列數超過,它也應該使用滾動來顯示內容。下面是它的樣子。 此應用程序也適用於iPhone和iPad,因此應考慮Auto Layouts
。如何製作UITableViewCell中行數和列數未知的表格
EDIT
紅色的雜交也應該是在我的控制,因爲我需要顯示其中用戶已經打勾蜱。
如何在我的UITableViewCell
中創建未知行數和列數的table
?我正在創建一個調查應用程序,報告也可以包含矩陣類型的問題。我如何查看我的TableViewCell中的那些。如果行數和列數超過,它也應該使用滾動來顯示內容。下面是它的樣子。 此應用程序也適用於iPhone和iPad,因此應考慮Auto Layouts
。如何製作UITableViewCell中行數和列數未知的表格
EDIT
紅色的雜交也應該是在我的控制,因爲我需要顯示其中用戶已經打勾蜱。
我在TableView's Cell
插入UIScrollView
和動態使用爲行和列的數量的基礎上循環產生的行和列。爲列和行創建動態標籤,爲imageViews創建勾號和十字,並通過使用x和y保持管理大小,並在最後根據滾動的x和y設置scrollView的內容。
You can not implement Above problem using tableview,i have same problem in my app and i have solve as below by creating custom label.i have face this problem in collect customer rating.....this ans may help you
put this code in viewdidload() method
arrSelectTag = [[NSMutableDictionary alloc]init];
arrTitle = [[NSMutableArray alloc]initWithObjects:@"Surf Lessons", @"Mojo Surf Coach",@"Mojo Surf Staff",@"Food",@"Accommodation",@"Transport",@"Trip Guide(if on Mojo Tour)",@"Head Surf Coach", nil];
arrHeading = [[NSMutableArray alloc]initWithObjects:@"How Would You Rate...",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"N/A", nil];
int widthTitle = viewGrade.frame.size.width/4;
int widthScore = (viewGrade.frame.size.width - widthTitle)/11;
int x = 0, y = 0;
for (int i=0; i<12; i++) {
if (i == 0) {
lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(x, y, widthTitle, 30)];
x += widthTitle;
}else{
lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(x, y, widthScore,30)];
x += widthScore;
}
lblTitle.textColor = [UIColor whiteColor];
lblTitle.font = [UIFont fontWithName:@"JockeyOne-Regular" size:16.0];
lblTitle.text = [arrHeading objectAtIndex:i];
lblTitle.layer.borderColor = [UIColor whiteColor].CGColor;
lblTitle.layer.borderWidth = 1.0;
lblTitle.textAlignment = NSTextAlignmentCenter;
[viewGrade addSubview:lblTitle];
}
tag = 1;
natag = 100;
y = 30;
tagCount = 0;
for (int i = 0; i<8; i++) {
x = 0;
for (int j = 0; j<12; j++) {
if (j == 0) {
lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(x, y, widthTitle, 30)];
lblTitle.textColor = [UIColor whiteColor];
lblTitle.font = [UIFont fontWithName:@"JockeyOne-Regular" size:16.0];
lblTitle.text = [arrTitle objectAtIndex:i];
lblTitle.layer.borderColor = [UIColor whiteColor].CGColor;
lblTitle.layer.borderWidth = 1.0;
lblTitle.textAlignment = NSTextAlignmentCenter;
[viewGrade addSubview:lblTitle];
x += widthTitle;
}else{
btnSelect = [[UIButton alloc]initWithFrame:CGRectMake(x, y, widthScore, 30)];
btnSelect.layer.borderColor = [UIColor whiteColor].CGColor;
btnSelect.layer.borderWidth = 1.0;
[btnSelect setImage:[UIImage imageNamed:@"select.png"] forState:UIControlStateSelected];
[btnSelect addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside];
int val;
if (j==11) {
btnSelect.tag = natag;
if (self.dictDisplay.count>0) {
if ([[arrVoteDisplay objectAtIndex:i]isEqualToString:@"N/A"]) {
val = i*100 + 100;
if (val == natag) {
btnSelect.selected = TRUE;
tagCount += 10;
}
}
}
natag += 100;
}else{
btnSelect.tag = tag;
if (self.dictDisplay.count>0) {
val = [[NSString stringWithFormat:@"%@",[arrVoteDisplay objectAtIndex:i]]intValue];
val = val + tagCount;
if (val == tag) {
btnSelect.selected = TRUE;
tagCount += 10;
}
}
tag++;
}
NSLog(@"i=%d, j=%d, Tag = %ld",i, j, (long)btnSelect.tag);
[viewGrade addSubview:btnSelect];
x += widthScore;
}
}
y += 30;
}
這個問題不符合我的要求,不過謝謝你的回答:) –
爲什麼一個表視圖而不是一個集合視圖? – Wain
@因爲我在我的TableView中顯示了整個問題列表。包含問題的部分標題和顯示選項(答案)的單元格數量。所以我需要在'tableView's Cell'中實現這個問題 –