multiple UIAlertView issue

前端 未结 1 1684
梦谈多话
梦谈多话 2021-01-20 02:59

I have an issue with my code, I have two blocks of code of UIAlertViews one with cancel and ok button, and the other to make a UIImagePicker

-(IBAction)publi         


        
1条回答
  •  粉色の甜心
    2021-01-20 03:29

    A couple ways.

    1)

    See how the delegate method is called?

    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    

    From the alertView parameter, you can tell which alert did the calling (if you set cargaImagen and publicaPeticion's alertviews to separate instance variables).

    2)

    Another (and probably easier) thing you could do is to set a tag property on your alertView.

    In your 'cargaImagen' method and right after you create the UIAlert, set the tag to 1 via alert.tag = 1;.

    Then, in your alertView:clickedButtonAtIndex: delegate method, when alertView.tag == 1, you'll know it comes from cargaImagen and if it's 2 (or zero), you know it comes from publicaPeticion.

    0 讨论(0)
提交回复
热议问题