Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Set autocapitalization based on the first letter of default value #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions FBTweak/_FBTweakTableViewCell.m
Expand Up @@ -314,6 +314,7 @@ - (void)_updateValue:(FBTweakValue)value primary:(BOOL)primary write:(BOOL)write
} else if (_mode == _FBTweakTableViewCellModeString) {
if (primary) {
_textField.text = value;
[self _updateAutocapitalizationType];
}
} else if (_mode == _FBTweakTableViewCellModeInteger) {
if (primary) {
Expand Down Expand Up @@ -347,4 +348,18 @@ - (void)_updateValue:(FBTweakValue)value primary:(BOOL)primary write:(BOOL)write
}
}

- (void)_updateAutocapitalizationType
{
unichar firstLetter = _textField.text.length > 0
? [_textField.text characterAtIndex:0]
: 0;
BOOL isUppercase = [[NSCharacterSet lowercaseLetterCharacterSet] characterIsMember:firstLetter];
if (isUppercase) {
_textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
return;
}

_textField.autocapitalizationType = UITextAutocapitalizationTypeSentences;
}

@end