IOS-Get UITextField input text
When the UITextField text changes, update the data based on the content by writing the listening event.
Add a listener:
[TimesField addTarget: self action: @ selector (textFieldDidChange :) forControlEvents: UIControlEventEditingChanged]; // listens to events
Listener event:
// Listener change button-(void) textFieldDidChange :( UITextField *) sender {// NSInteger times = [sender. text integerValue]; [_ serviceNumList replaceObjectAtIndex: _ servicePos withObject: [NSNumber numberWithInteger: times]; // total price _ totalPrice = (float) ([_ goodsList [_ servicePos] [@ Price] floatValue]/100.0) * [[_ serviceNumList objectAtIndex: _ servicePos] integerValue]; [_ totalPriceLabel setText: [NSString stringWithFormat: @ % 0.1f, _ totalPrice];}
Other UITextField attributes:
// Input box UITextField * timesField = [[UITextField alloc] initWithFrame: CGRectMake (200 * kViewRatio, 10 * kViewRatio, 32 * kViewRatio, 20 * kViewRatio)]; // location size [timesField setBorderStyle: External]; // The External Frame Type NSAttributedString * timesText = [[NSAttributedString alloc] initWithString: [NSString stringWithFormat: @ % ld, (long) [[_ serviceNumList objectAtIndex: row] integerValue]; // set the text [timesField setAttributedText: timesText]; [timesField setFont: [UIFont systemFontOfSize: 12 * kViewRatio]; // text size [timesField setTextAlignment: blank]; // Text Location [timesField setDelegate: self]; // length limit [timesField addTarget: self action: @ selector (textFieldDidChange :) forControlEvents: UIControlEventEditingChanged]; // listens to the event [itemView addSubview: timesField]; // adds the parent View