在单击更多段时,段控制器应使用数组中的下三个值重新创建自身,依此类推。我怎样才能做到这一点?
最佳答案
做这个。
取整数保持编号。点击更多按钮的次数。
_ noOfTimes = 0;
现在,当点击“更多”按钮时,可以像这样从阵列加载数据
- (void)method:(id)sender {
NSRange range = NSMakeRange(_noOfTimes * (length - 1), length); // length will be 3 in your case "1 back + 3 items + 1 more". Do the reverse when back button is pressed. decrease value of _noOfTimes first though ;)
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
NSArray *tempArray = [tempArray objectsAtIndexes:indexSet];
//now change title of the segment controllers accordingly
//and in the end
_noOfTimes ++;
}
尝试这种方式。 :)
关于ios - 我有一个包含20个值的数组。我想一次在一个标题 Controller 上显示3个项目的段 Controller 上的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17525912/