2009年11月20日星期五

iPhone UIAlertView Sample

初学iPhone开发:
用到UIAlertView,以后开发应该能用到记录之
两个例子,
第一个

-(IBAction)buttonPressed:(id)sender
{
NSString *favouriate = [sender titleForState:UIControlStateNormal];
NSString *alertViewText = [[NSString alloc] initWithFormat:@"You choose the %@ as your favouriate Apple computer",favouriate];


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Favoriate Mac!"
message:alertViewText
delegate:nil
cancelButtonTitle:@"Go back"
otherButtonTitles:@"Yes!", nil];

[alert show];
[alert release];
}
Screen shot 2009-11-20 at 5.12.48 PM.png

第二个
-(IBAction)buttonPressed:(id)sender
{
NSString *favouriate = [sender titleForState:UIControlStateNormal];
NSString *alertViewText = [[NSString alloc] initWithFormat:@"You choose the %@ as your favouriate Apple computer",favouriate];
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"favoriate Text" message:alertViewText delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];


[alert show];
[alert release];
}

Screen shot 2009-11-20 at 5.18.48 PM.png

没有评论:

发表评论