Soru & Cevap

UiAlertView çakışması hk.

05.05.2017 - 08:20

Arkadaşlar Merhaba 

AlertView kullanıyorum iki tane farklı action butonlarında fakat çakışma meydana geliyor 1 ci alertview butonları düzgün çalışmasına rağmen diğer action butonuna bastığımda çıkan alertview butonları 1cinin görevlerini gerçekleştiriyor.kodlar aşağıdaki gibi yardımcı olursanız sevinirim.

-(IBAction)sendMailhedef:(id)sender

{

    UIAlertView * birinci =[[UIAlertView alloc] initWithTitle:@"Birinci Alert View" message:@"Sube Seçimi" delegate:self cancelButtonTitle:@"Vazgeç" otherButtonTitles:@"Bağcılar",@"Beylikdüzü",@"Seyrantepe",@"Maslak" ,nil];

    

    [birinci show];

}

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

        if (buttonIndex==1)

        {

            {

                

            NSArray *recipients = [NSArray arrayWithObjects:@"ornek@hotmail.com", nil];

            // email Subject

            NSString *subject = @"merhaba hk.";            

            MFMailComposeViewController *Composer = [[MFMailComposeViewController alloc]init];

            

            Composer.mailComposeDelegate = self;

            [Composer setSubject:subject];

            [Composer setMessageBody:body isHTML:NO];

            [Composer setToRecipients:recipients];

            [Composer setCcRecipients:ccRecipients];

            //get the filePath resource

            

            NSString *filePath = [[NSBundle mainBundle]pathForResource:@"logo" ofType:@"jpg"];

            

            //Read the file using NSData

            

            //  NSData *fileData = [NSData dataWithContentsOfFile:filePath];

            

            //   NSString *mimeType = @"image/png";

            

            //Add attachement

            

            //[Composer addAttachmentData:fileData mimeType:mimeType fileName:filePath];

            

            //Present it on the screen

            

            

            [self presentViewController:Composer animated:YES completion:nil];

            }}

        else if (buttonIndex==2)

            

            {

 

    

    NSArray *recipients = [NSArray arrayWithObjects:@"ornek2@hotmail.com.tr", nil];

    // email Subject

    NSString *subject = @"selam hk.";

    //email body

    

    MFMailComposeViewController *Composer = [[MFMailComposeViewController alloc]init];

    

    Composer.mailComposeDelegate = self;

    [Composer setSubject:subject];

    [Composer setMessageBody:body isHTML:NO];

    [Composer setToRecipients:recipients];

  

    //get the filePath resource

    

    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"logo" ofType:@"jpg"];

    

    //Read the file using NSData

    

    //  NSData *fileData = [NSData dataWithContentsOfFile:filePath];

    

    //   NSString *mimeType = @"image/png";

    

    //Add attachement

    

    //[Composer addAttachmentData:fileData mimeType:mimeType fileName:filePath];

    

    //Present it on the screen

    

    

    [self presentViewController:Composer animated:YES completion:nil];

    

    

}

        else if (buttonIndex==3)

        {

            NSArray *recipients = [NSArray arrayWithObjects:@"merhaba@icloud.com", nil];

            

            NSString *subject = @"merhaba hk.";

 

            

            

            MFMailComposeViewController *Composer = [[MFMailComposeViewController alloc]init];

            

            Composer.mailComposeDelegate = self;

            [Composer setSubject:subject];

            [Composer setMessageBody:body isHTML:NO];

            [Composer setToRecipients:recipients];

 

            NSString *filePath = [[NSBundle mainBundle]pathForResource:@"logo" ofType:@"jpg"];

            

            

            [self presentViewController:Composer animated:YES completion:nil];

            

        }

        else if (buttonIndex==4)

        {

            NSArray *recipients = [NSArray arrayWithObjects:@"erhan@hotmail.com" nil];

            

            NSString *subject = @"reyhan hk.";

            

            MFMailComposeViewController *Composer = [[MFMailComposeViewController alloc]init];

            

            Composer.mailComposeDelegate = self;

            [Composer setSubject:subject];

            [Composer setMessageBody:body isHTML:NO];

            [Composer setToRecipients:recipients];

          

            NSString *filePath = [[NSBundle mainBundle]pathForResource:@"logo" ofType:@"jpg"];

            

            

            [self presentViewController:Composer animated:YES completion:nil];

            

        }

    }

 

-(IBAction)sendMaildigeri:(id)sender

{

    UIAlertView * ikinci =[[UIAlertView alloc] initWithTitle:@"Depo" message:@"Sube Seçimi" delegate:self cancelButtonTitle:@"Vazgeç" otherButtonTitles:@"Güneşli",@"Kağıthane",@"Trakya", nil];

       [ikinci show];

}

 

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

    

    if (buttonIndex==1)

    {

        

        {

            NSArray *recipients = [NSArray arrayWithObjects:@"burak@yahoo.com", nil];

            

            NSString *subject = @"Sipariş hk.";

           

            MFMailComposeViewController *Composer = [[MFMailComposeViewController alloc]init];

            

            Composer.mailComposeDelegate = self;

            [Composer setSubject:subject];

            [Composer setMessageBody:body isHTML:NO];

            [Composer setToRecipients:recipients];

 

            NSString *filePath = [[NSBundle mainBundle]pathForResource:@"logo" ofType:@"jpg"];

            

            

            [self presentViewController:Composer animated:YES completion:nil];

        }}

       

        

            else if (buttonIndex==2)

            {

       

        NSArray *recipients = [NSArray arrayWithObjects:@"e.bozar@yahoo.com", nil];

        

        NSString *subject = @"Sipariş hk.";

        

              

        MFMailComposeViewController *Composer = [[MFMailComposeViewController alloc]init];

        

        Composer.mailComposeDelegate = self;

        [Composer setSubject:subject];

        [Composer setMessageBody:body isHTML:NO];

        [Composer setToRecipients:recipients];

       

        

        

        NSString *filePath = [[NSBundle mainBundle]pathForResource:@"logo" ofType:@"jpg"];

        

        

        [self presentViewController:Composer animated:YES completion:nil];

 

            }

            else if (buttonIndex==3)

            {

                

                NSArray *recipients = [NSArray arrayWithObjects:@"g.atalay@yahoo.com", nil];

                

                NSString *subject = @"Sipariş hk.";

                

             

                

                MFMailComposeViewController *Composer = [[MFMailComposeViewController alloc]init];

                

                Composer.mailComposeDelegate = self;

                [Composer setSubject:subject];

                [Composer setMessageBody:body isHTML:NO];

                [Composer setToRecipients:recipients];

              

                

                

                NSString *filePath = [[NSBundle mainBundle]pathForResource:@"logo" ofType:@"jpg"];

                

                

                [self presentViewController:Composer animated:YES completion:nil];

            }

    

}

 

 

 

4 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-72689-1486621271.jpg
levent.yildirim
10.05.2017 - 03:00

Merhaba. Alertlerine tag vermen gerekiyor. Butun alertviewler ayni delegate metodun icine duser burada ayni buttonindex leri ayirdigin gibi alertleride taglara gore ayirman gerekiyor. Ornegin 1. alertview in tag ina 0 digerine 1 verirsin   -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex metodunun icinde de alertview in tag i 0 veya 1 ise diye ayirip islemlerini yapabilirsin.