Here we learn about the UIAlertView Of iphone Application: just how to show the Alert Messages in Iphone Application.
Alter View:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"MSG" delegate:nil/self cancelButtonTitle:@"OK" otherButtonTitles:@"cancel",nil];
alert.tag = 1;
[alert show];
[alert release];
- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alert.tag == 1)
{
if(buttonIndex == 0)
// statements
else
//statements
}
}
Change UIAlertView Button Color:
Create the object of UIAlertView , the call automatically following method:
- (void)willPresentAlertView:(UIAlertView *)alertView
{
[[[alertView subviews] objectAtIndex:1] setBackgroundColor:[UIColor redColor]];
/*
Here index 0 = Title , 1 = cancel Button , 2,3.... = otherButton
*/
}
Alter View without Button:
UIAlertView *baseAlert = [[UIAlertView alloc]
initWithTitle:@""
message:@"Message to user \n with asynchronous \ninformation"
delegate:self cancelButtonTitle:nil
otherButtonTitles: nil];
[NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector: @selector(performDismiss:) userInfo:nil repeats:NO];
[baseAlert show];
baseAlert.frame = CGRectMake(0,190,320, 120);
- (void) performDismiss: (NSTimer *)timer
{
[baseAlert dismissWithClickedButtonIndex:0 animated:NO];
}
Thanks
Keep smiling and Happy Programming.
No comments:
Post a Comment