views:

227

answers:

1

Hi

My alertview appears twice and requires 2 user clicks to dismiss.

    - (void) showAlert: (NSString *) message
{
 UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"You chose"
             message: message
            delegate: self
            cancelButtonTitle:@"Cancel"
            otherButtonTitles:@"ok",nil];
 av.tag = SLIDER_ALERT;
 [av show];

}

I am then releasing the alertview in the delegate method "alertView: (UIAlertView *) alertView clickedButtonAtIndex: (int) index"

I suspect the problem is that I have built my own view hierarchy programmaticaly. I have one parent view for the viewcontroller. Under that i have 2 other views (parentView -> subview1 and subview2). I've tried to call [self.view addSubview: av] but that does not work. Neither does bringToFrontSubView:

Any help would be much appreciated

Peyman

A: 

The Alert code is fine (other than the release, mentioned in the comments).

[av show] is all that's required to show a view. You don't add UIAlertViews as subviews.

Jordan
I've narrowed the problem to the interaction between the slider and the UIAlertview. The UISlider is calling its alertView: clickedButtonAtIndex: delegate twice. I have set the UISlider.continous property to NO so theoretically the slider should return only 1 (end value) on slider release. But its not. Its calling the delegate x2. Any suggestions?
Peyman