English 中文(简体)
UIAlertView 子视图定位
原标题:UIAlertView subview positioning

我有一个警告View 当用户正在更改标签时会弹出提醒View

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

现在,我处理按钮点击事件,在此事件中,我想显示另一个带有进度的警告View 的子视图

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

if the user does touch the save button i show an alertView with a progressView as a subview this method is called in the playMovie method

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

问题是:

如果我显示警报... View 正常情况下, 子视图定位是正常的

但是如果我在

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

View 是不适当的

问题回答

您为什么想要在 uiwardview 中显示进度? UI 状态预览是模式化的 。 使用您自己的视图, 并显示您完全控制的方式, 您可以添加一个暂停、 继续和停止按钮, 您可以显示您想要的所有信息 。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签