1 textField的键盘弹出设置Keyboard type 为number Pad 由于text Field里面是string所以要先吧text转为数字相加之后再转为string显示
//NSString *s1 = self.shuzi1.text;
NSString *s2 = self.shuzi2.text;
int n1 = [s1 intValue];
int n2 = [s2 intValue];
int n = n1 + n2;
self.jieguo.text = [NSString stringWithFormat:@"%d",n];
// self.jieguo.text = [NSString stringWithFormat:@"%d" [[self.shuzi1.text intValue] + [self.shuzi2.text intValue]]];//中括号多了
int n = [self.shuzi1.text intValue] + [self.shuzi2.text intValue];
//self.jieguo.text = [NSString stringWithFormat:@"%d",[self.shuzi1.text intValue] + [self.shuzi2.text intValue]];
还有点击计算之后呢需弹回键盘 (2种)
//
[self.shuzi1 resignFirstResponder];
[self.shuzi2 resignFirstResponder];
//
[self.view endEditing:YES ];