NStimer + FLIPAction (transition)

画面開始後5秒経つと画面遷移するプログラム完成。(プロジェクト作成時にユーティリティがたを選ぶ)
IBAction型をvoidがたに変更してうまくいくのに吉田戦車のいじめてくんを見ながら4時間程度かかった。

  • (void)viewDidLoad {

[super viewDidLoad];

[NSTimer
scheduledTimerWithTimeInterval:5.0f
target:self
selector:@selector(showInfo:)
userInfo:nil
repeats:YES
];
}

  • (void)showInfo:(id)sender {


FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
controller.delegate = self;

controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];

[controller release];
}

Nstimer+uialert

viewdidload以下に2秒おきにメッセージが出てくるうざい事この上ないコード書いた。動いた。


  • (void)viewDidLoad {

[super viewDidLoad];

[NSTimer
scheduledTimerWithTimeInterval:2.0f
target:self
selector:@selector(hoge:)
userInfo:nil
repeats:YES
];
}
-(void)hoge:(NSTimer*)timer{

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"information"
message:@"いんふぉめーしょんだよ"
delegate:self
cancelButtonTitle:@"ok"
otherButtonTitles:nil ];
alert.message=[NSString stringWithFormat:@"%d", 123456];

[alert show];
[alert release ];

}

数値型から文字型にしてテキストフィールドへ返す

参考元http://gihyo.jp/dev/serial/01/iphone/0005?page=2

  • (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;

[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 ];
[income setText:[NSString stringWithFormat:@"%d", str3]];

}