在CellForRow那里
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(textFieldEditChanged:)
name:@"UITextFieldTextDidChangeNotification" object:cell.infoTF];
- (void)textFieldEditChanged:(NSNotification *)obj
{
LMSNewAddPlanTableCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
NSString *toBeString = cell.infoTF.text;
NSString *lang = self.textInputMode.primaryLanguage;//键盘输入模式
if ([lang isEqualToString:@"zh-Hans"])
{
if (toBeString.length > 50)
{
cell.infoTF.text = [toBeString substringToIndex:50];
self.fuzhiPlanDetailModel.plan_title = cell.infoTF.text; //
[MBProgressHUD showText:@"最大可输入50字" duration:3.0];
} else {
self.fuzhiPlanDetailModel.plan_title = cell.infoTF.text; //
}
}
else
{
if (toBeString.length > 50)
{
cell.infoTF.text = [toBeString substringToIndex:50];
self.fuzhiPlanDetailModel.plan_title = cell.infoTF.text; //
} else {
self.fuzhiPlanDetailModel.plan_title = cell.infoTF.text; //
}
}
}