Add UIActivityIndicatorView to UIActionSheet

I'm trying to add UIActivityIndicatorViewin UIActionsSheetthe following way:

UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:nil
                                  delegate:sharedInstance
                                  cancelButtonTitle:nil
                                  destructiveButtonTitle:nil
                                  otherButtonTitles:nil];

for(NSMutableDictionary *dict in moreStructure)
   {
       NSString *value = [dict valueForKey:TITLE_PARAMETER];
       [actionSheet addButtonWithTitle:value];
   }
    [actionSheet addButtonWithTitle:@"Cancel"];
    actionSheet.cancelButtonIndex = [moreStructure count];
    [actionSheet showInView:((SectionViewController *)sharedInstance.currentViewController).view];
    UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    activityView.frame = CGRectMake(100, 500, 15, 15);
    [activityView startAnimating];
    [actionSheet addSubview:activityView];

When appears UIActionSheet, I do not see on it UIActivityIndicatorView. Please help me.

+4
source share
2 answers

I tried this and it works ... Please check the framework of activityView ... because its y 500 ...

UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:nil
                                  delegate:nil
                                  cancelButtonTitle:@"Test"
                                  destructiveButtonTitle:@"Test"
                                  otherButtonTitles:nil];

    [actionSheet showInView:self.view];

    UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    activityView.frame = CGRectMake(100, 5, 15, 15);
    [activityView startAnimating];
    [actionSheet addSubview:activityView];

    activityView.backgroundColor = [UIColor redColor];
    actionSheet.backgroundColor = [UIColor greenColor];
+2
source
activityView.frame = CGRectMake(100, 500, 15, 15);

// this means that the above should change

activityView.frame = CGRectMake(10, 50, 300, 400);
+2
source

Source: https://habr.com/ru/post/1525424/


All Articles