0

There is an issue with an UIAlertView when i add to this a lot of buttons. Then the alertView seems to be destroyed. This happens only to prior version of iOS 7. On iOS 7 and posterior versions it seems ok.Here is a screenshot of my problem.Can i fix it?

problem

- (void) sortTotalMnhmeia{

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Ταξινόμηση" message:@"Επιλέξτε είδος ταξινόμησης" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Αξιοθέατα",@"Δραστηριότητες",@"Διαμονή",@"Χωριά",@"Προϊόντα",@"Όλες οι κατηγορίες",nil];

[alert show];

}

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

   if (buttonIndex == 0)
{
    NSLog(@"Cancel Tapped.");
}
else if (buttonIndex == 1)
{
    [self.mapView removeAnnotations:self.annotations];

    [self.annotations removeAllObjects];

    self.annotations=[[NSMutableArray alloc] init];


    NSLog(@"yo  %d",self.annotations.count);



    for(int i=0; i<self.allGroups.count; i++){

        Group *assistantGroup=assistantGroup=[self.allGroups objectAtIndex:i];

        if ([assistantGroup.secondLevel intValue]==1) {



            if ([assistantGroup.thirdLevel intValue]==1) {
                self.chooseMarker=@"Museum";
            }
            else if ([assistantGroup.thirdLevel intValue]==2) {
                self.chooseMarker=@"Art";
            }
            else if ([assistantGroup.thirdLevel intValue]==3) {
                self.chooseMarker=@"Religious";
            }
            else if ([assistantGroup.thirdLevel intValue]==4) {
                self.chooseMarker=@"Monument";
            }
            else if ([assistantGroup.thirdLevel intValue]==5) {
                self.chooseMarker=@"Natural";
            }
            else if ([assistantGroup.thirdLevel intValue]==6) {
                self.chooseMarker=@"Beach";
            }

            NSLog(@"************ %@ %@ %@",assistantGroup.title,assistantGroup.latitude,assistantGroup.longitude);

            Annotation *ann = [[Annotation alloc] initWithLong:[assistantGroup.longitude doubleValue] Lat:[assistantGroup.latitude doubleValue] iconNumber:0];
            ann.title = assistantGroup.title;
            ann.subtitle=@"";
            ann.type=self.chooseMarker;

            [self.annotations addObject:ann];

        }





        //ann.type=assistantGroup.kind;

    }



    [self.mapView addAnnotations:self.annotations];

}

.....

}
Gabriel.Massana
  • 8,165
  • 6
  • 62
  • 81
hoya21
  • 893
  • 7
  • 24

1 Answers1

0

You should consider using a modal view controller instead since using lots of buttons in an AlertView can be confusing. I don't see the reason adding lots of buttons to a single alert view. A modal VC has all the flexibility you are looking for. Otherwise an action sheet would be preferable too.

But to answer the question: Add a "More" button last that spawns a second AlertView with the buttons that don't fit the first alert view. Alert VCs don't rescale the way they do on iOS versions above 7.0.

Widerberg
  • 1,118
  • 1
  • 10
  • 24
  • Alexander thanks for your answer.As you can see from the screenshot,the purpose of these alert view is to filter the items that have to be shown on the map,so i have to include to the alert view as many buttons as the number of kinds that are shown on the map.Also that is the structure of this controller and it can not change. Any other advice? – hoya21 Jul 17 '14 at 08:38
  • Haha, having a hard time understanding greece ;) Then just add a more button that dismisses the first alert view and pops up a new one with the buttons that don't fit. "Problem solved". Consider having the least used feature/button on the second screen though. – Widerberg Jul 17 '14 at 08:41
  • Hehe.It is a nice idea. I will consider your advice.Another thought is a slide-out-sidebar that has more work to be done.Thank you anyway! – hoya21 Jul 17 '14 at 08:47