문제

I'd need to remove all columns from a table except the first two. I am Iterating over the table columns and am stuck at the part where I have to delete the column based on the index.

So far I have this:

int x;
for (x = 2; x < [table numberOfColumns]; x++) {
    [table removetablecolumn:([table column:x])]

}
도움이 되었습니까?

해결책

Your code should go this way:

for (NSInteger tcIndex = self.tableView.tableColumns.count-1; tcIndex >= 2; tcIndex--){
    [self.tableView removeTableColumn:[self.tableView tableColumns][tcIndex]];
}

You need to count total columns in the tableview and then remove them.

What you are doing is that iterating through number of rows, which is incorrect.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top