开发者

I am trying to add segments to a segmented controller using a for loop and failing

I am trying to add segments to a segmented controller that is drawn in the .xib with five segments. When I try to compile this loop, I get the following error: "Expected ';' before animated."

What am I doing wron开发者_C百科g? I know that this is a bonehead level question, but I cannot see the answer for the life of me right now....

TIA!

Steve O'Sullivan

// inserting names into the UISegmentedControl which has five segments in the xib
for (i = 0; i < 5; i++)
{
 insertSegmentWithTitle:[NSString stringWithFormat:@"P-%d", i]
      atIndex:i
      animated:NO;
}


You're missing the name of the UISegmentedControl that you are trying to send the insertSegmentWithTitle:atIndex:animated: message to. Assuming that you have a property in your interface defined something like:

IBOutlet UISegmentedControl *mySegControl;

and that the outlet is wired up in InterfaceBuilder to the control, you probably want something like this:

// inserting names into the UISegmentedControl which has five segments in the xib
for (i = 0; i < 5; i++)
{
 [mySegControl insertSegmentWithTitle:[NSString stringWithFormat:@"P-%d", i]
      atIndex:i
      animated:NO];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜