2 for 2012 for_2012 于 2013.06.03 11:26 提问

segmentedControl打开顺序颠倒
 - (void)viewDidLoad
    {
   [super viewDidLoad];

    [self.segmentedControl removeAllSegments];
    s = 0;
    for (NSDictionary *dictionary in self.top.segments) {
        [_segmentedControl insertSegmentWithTitle:dictionary [@"sTitle"] atIndex:s animated:NO];
        self.bioTextView.text = [NSString stringWithFormat:@"%@", dictionary [@"sData"]];
    }}

为什么segmentedControl以颠倒的顺序开始?请高手指点。谢谢

1个回答

zhanglei5415
zhanglei5415   Rxr 2013.06.03 16:01
已采纳

变量 s的值一直为0 ,没有在执行完成后累加

 for (NSDictionary *dictionary in self.top.segments) {
        [_segmentedControl insertSegmentWithTitle:dictionary [@"sTitle"] atIndex:s animated:NO];
        self.bioTextView.text = [NSString stringWithFormat:@"%@", dictionary [@"sData"]];
        s++; //这里来累加
    }}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!