0
votes

I am developing an iPhone application, in which I want to use customized alert sheet. The customization is required since I want to set image for Alert-Sheet buttons, change the size of these button etc.

I have done the following things:

  1. Created UIView with customized controls that I wanted.
  2. Created and displayed UIAlertView
  3. In the delegate method of UIAlertView (UIAlertViewDelegate) i.e

    - (void)willPresentAlertView:(UIAlertView *)alertView
    

    I am removing all the subviews of UIAlertView and adding my customized view as subview.

Everything works fine till here. Since I have used customized buttons, I need to remove the alert sheet explicitly in the Action Method of the button by calling dismissWithClickedButtonIndex:animated: on UIAlertView. Even though the UIALertView gets dismissed, it takes around 0.5 second to get dismissed. Can someone help me out to solve the problem of this delay in dismissing OR some other way of customization of Alert View buttons.

Thanks and Regards, Deepa

3
Need to know the code you're using to dismiss it.Thomas Clayson
[alertView dismissWithClickedButtonIndex: 0 animated: NO]spd

3 Answers

0
votes

I could get it worked by passing YES to dismissWithClickedButtonIndex:animated: call i.e [alertView dismissWithClickedButtonIndex: 0 animated: YES]. Initially I was passing the flag as NO. But, I don't know whey it takes less time if we pass the animation flag as YES. Anyone knows this?

0
votes

Instead of doing this

/*
1. Created UIView with customized controls that I wanted.
2. Created and displayed UIAlertView
3. In the delegate method of UIAlertView (UIAlertViewDelegate)
*/

do this:

Create a class like this:

@interface CustomAlertView  : UIAlertView
{
  //For ex:

   UIButton *myCustomButton;
//and other custom controls
}

Implement it in following method:

-(id)init
{

}

In the above method use:

[self addSubView: myCustomButton];

I have given just the idea. I have code but not presently to share with you. If you are not able to implement the above I will provide later.

Thanks.

0
votes

Here is the library which can solve your UIAlertView Customisation issue. It can also work as UIActionSheet. It has very good customisation options.

https://github.com/Codigami/CFAlertViewController