将UIActivityIndi​​catorView添加到UIActionSheet

时间:2014-02-05 13:25:04

标签: ios objective-c uiactionsheet uiactivityindicatorview

我正在尝试以这种方式向UIActivityIndicatorView添加UIActionsSheet

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];

但是,当出现UIActionSheet时,我看不到UIActivityIndicatorView。求你帮帮我。

2 个答案:

答案 0 :(得分:2)

我试过这个,这是有效的...请检查activityView的框架...因为它的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];

答案 1 :(得分:2)

activityView.frame = CGRectMake(100, 500, 15, 15);

//这就是上面的内容必须改变

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