假设我有一个UITextField(默认空白),一个UISegmentedControl(默认2个段名为“1”和“2”),还有一个UILabel(默认文本“None”)在我的笔尖 。我希望能够做到以下几点:
我知道如何设置一个能够捕获在UITextField中输入的数字的IBAction,但是上面的#2怎么做,那就是我如何“重绘”UISegmentControl以得到3个名为“1”,“2”的段,和“3?”
我知道如何做#3。
答案 0 :(得分:0)
您可以使用insertSegmentWithTitle:(NSString *) atIndex:(NSUInteger) animated:(BOOL)方法完成此操作。
像:
int indexOfSegment = yourSegmentController.numberOfSegments;
[yourSegmentController insertSegmentWithTitle:yourTextfield.text atIndex:indexOfSegment animated:YES];