Katedral Pillon
Katedral Pillon

Reputation: 14844

How to set character limit in iOS

In android all I have to do in the equivalent of "interface builder" is

 android:maxLines="140";//twitter's character limit

Is there an equivalently simple method for iOS?

Upvotes: 0

Views: 699

Answers (2)

Feng Lin
Feng Lin

Reputation: 593

Use the UITextFieldDelegate to listen the length of input, you can see this uitextfield-maximun

also you need adapt the protocol and set the delegate to your textfield.

Upvotes: 1

Dean Leitersdorf
Dean Leitersdorf

Reputation: 1341

int n = 140;

NSString *displaySTR = ......
if ([displaySTR length] > n) {
displaySTR = [string substringToIndex:n];
}

Upvotes: 0

Related Questions