alertの中に変数を格納する。これもすぐできた。OJT~C データ型にうるさすぎ
- (IBAction)executeCalc:(id) sender {
[income resignFirstResponder];
[cost resignFirstResponder];
int str = [income.text intValue];
int str2 = [cost.text intValue];
int str3 = str - str2;
[dpi setText:[NSString stringWithFormat:@"%d", str3]];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"information"
message:@"いんふぉめーしょんだよ"
delegate:self
cancelButtonTitle:@"ok"
otherButtonTitles:@"website",nil ];
alert.message=[NSString stringWithFormat:@"%d", str3];
[alert show];
[alert release ];
alertはとくに苦労せずにかけた。メソッドの中に突っ込んで終わり。
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
- (IBAction)executeCalc:(id) sender {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"information"
message:@"いんふぉめーしょんだよ"
delegate:self
cancelButtonTitle:@"ok"
otherButtonTitles:@"website",nil ];
[alert show];
[alert release ];
[income resignFirstResponder];
[cost resignFirstResponder];
int str = [income.text intValue];
int str2 = [cost.text intValue];
int str3 = str - str2;
[dpi setText:[NSString stringWithFormat:@"%d", str3]];
}
中身のないVOIDすら不要
やはり中身のないVOIDすら不要であったようである。この部分を消しても機能する
さらに計算ボタンを押すとキーボードが隠れるように修正
中身のないvoidをつくり
income textfieldとcosttextfield にresignfirstresponder を格納すると
何故かキーボードが隠れるようになる。
#import "fqViewController.h"
@implementation fqViewController
@synthesize scroll;
@synthesize income;
@synthesize cost;
@synthesize calcButton;
@synthesize dpi;
- (void)textFieldResignFirstResponder {
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
- (IBAction)executeCalc:(id) sender {
[income resignFirstResponder];
[cost resignFirstResponder];
int str = [income.text intValue];
int str2 = [cost.text intValue];
int str3 = str - str2;
/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
■
uitextfieldでreturnを押したときにキーボードが引っ込むようにした。
selfだから自身に委譲し、ブール値がイエスになったときにキーボードが引っ込む
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
- (IBAction)executeCalc:(id) sender {
int str = [income.text intValue];
int str2 = [cost.text intValue];
int str3 = str - str2;
[dpi setText:[NSString stringWithFormat:@"%d", str3]];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if *1 {
// Custom initialization
}
return self;
}
*1:self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]