Pages

Showing posts with label UIAlertView. Show all posts
Showing posts with label UIAlertView. Show all posts

Sunday, May 30, 2010

Iphone: Alert View 2

Here we learn other things related to the UIAlertView Of iphone Application:


  • Alter View with multiline Button:
  • Alter View with Text field:






Alter View with multiline Button:
By default, if Alert has Three Button then its Come in Three line as

UIAlertView *alert = [[UIAlertView alloc] 
  initWithTitle:@"kamal " 
  message:@"Good Bye......." 
  delegate:self cancelButtonTitle:@"Cancel" 
  otherButtonTitles:@"hi", @"Hello ", nil]; 
    [alert show];


But If We Want to display Two Button with two different line then use below statement only before alert Show:
[alert setNumberOfRows:2];


Alter View with Text field:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Send Email" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Send", nil];
CGRect frame = CGRectMake(14, 35, 255, 23);
UITextField *emailField = [[UITextField alloc] initWithFrame:frame];
emailField.borderStyle = UITextBorderStyleBezel;
emailField.textColor = [UIColor blackColor];
emailField.textAlignment = UITextAlignmentCenter;
emailField.font = [UIFont systemFontOfSize:14.0];
emailField.placeholder = @"";
emailField.backgroundColor = [UIColor whiteColor];
emailField.autocorrectionType = UITextAutocorrectionTypeYes; // no auto correction support
emailField.keyboardType = UIKeyboardTypeEmailAddress; // use the default type input method (entire keyboard)
emailField.returnKeyType = UIReturnKeyDone;
emailField.delegate = self;
emailField.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
[alert addSubview:emailField];
[alert show];
[alert release];



Thanks

Keep smiling  and Happy Programming.

Iphone: Alert View

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.