Ios UIAlertView子视图定位

Ios UIAlertView子视图定位,ios,cocoa-touch,ipad,uiview,uialertview,Ios,Cocoa Touch,Ipad,Uiview,Uialertview,我有一个alertView,当用户更改选项卡时会弹出 UIAlertView *tempAlert = [[UIAlertView alloc] initWithTitle:@"Save Video?" message:@"Do you wish to save the video ?"

我有一个alertView,当用户更改选项卡时会弹出

UIAlertView *tempAlert = [[UIAlertView alloc] initWithTitle:@"Save Video?" 
                                                    message:@"Do you wish to save the video ?" 
                                                   delegate:self
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"Save",nil];
[tempAlert show];
[tempAlert setDelegate:self];
self.saveAlert = tempAlert;
[tempAlert release];
现在,我处理button click事件,在这个事件中,我想显示另一个带有progressView作为子视图的警报

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{
if ([alertView.title isEqualToString:@"Save Video?"])
{
    if (buttonIndex == [alertView cancelButtonIndex]) 
    {
        UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; //17.4.12
        // Adjust the indicator so it is up a few pixels from the bottom of the alert
        indicator.center = CGPointMake(self.saveAlert.bounds.size.width / 2, self.saveAlert.bounds.size.height - 40);
        [indicator startAnimating];
        [self.saveAlert addSubview:indicator];
        [indicator release];
        [(ImageCanvas1AppDelegate*)[[UIApplication sharedApplication] delegate] setMainAlert:self.saveAlert];


        [NSThread detachNewThreadSelector:@selector(performSaveOperationWithTabChangeToIndex:) toTarget:self withObject:[NSNumber numberWithInt:self.tab]];
    }
    else
    {
        [self performSelectorOnMainThread:@selector(playMovie)
                               withObject:nil waitUntilDone:YES];
    }
}
else
{
    if (buttonIndex == [alertView cancelButtonIndex]) 
    {
        [self.videoGenerator cancelVideoGeneration];
    }
}
}
如果用户按了保存按钮,我将显示一个alertView,其中progressView作为子视图 此方法在“playMovie”方法中调用

- (void)showAlert
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Generating Video" 
                                                message:@"Please wait!" 
                                               delegate:self cancelButtonTitle:@"Cancel" 
                                      otherButtonTitles:nil, nil];

[alert performSelectorOnMainThread:@selector(show)
                        withObject:nil
                     waitUntilDone:YES];
[alert setDelegate:self];
self.videoAlert = alert;
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
[progressView setFrame:CGRectMake(alert.bounds.size.width - progressView.bounds.size.width - 95,
                                  alert.bounds.size.height - progressView.bounds.size.height - 80, 
                                  progressView.bounds.size.width, 
                                  progressView.bounds.size.height)];
[alert addSubview:progressView];
self.progressView = progressView;
[progressView release];

[alert release];

[pool release];
}
问题是:

如果我正常显示alertView,则子视图定位很好

但是如果我在

-(无效)alertView:(UIAlertView*)alertView单击按钮索引:(NSInteger)按钮索引
{


progressView的it位置不正确

为什么要在uialertview中显示进度?uialertview是模态视图。创建自己的视图并显示,这样您就可以完全控制,您可以添加暂停、继续和停止按钮,您可以显示所需的所有信息。

为什么要在uialertview中显示进度e uialertview?uialertview是模态视图。创建您自己的视图并显示,这样您可以完全控制,您可以添加暂停、继续和停止按钮,您可以显示您想要的所有信息。

除非您想锁定应用程序,否则您不必创建模态视图。最简单的方法是创建一个70%透明度的全屏视图t、 例如,黑色背景。大小可以是您喜欢的任何大小。以模式进行操作的问题在于,整个应用程序stopsHere是您可以轻松完成的示例,它使您可以轻松添加背景任务。简单得多。除非您想锁定应用程序,否则不必创建模式视图。最简单的方法是创建fullscreen视图,例如70%透明的黑色背景。大小可以是您喜欢的任何大小。以模式进行操作的问题在于,整个应用程序stopsHere是您可以非常轻松完成的示例,它使您可以轻松添加背景任务。简单得多。