0
我有一個彈出當用戶改變標籤UIAlertView中子視圖定位
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];
的alertView現在我處理按鈕點擊事件,在這個事件中,我想展示一個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];
}
}
}
如果用戶觸摸保存按鈕i示出了具有一個progressView alertView作爲一個子視圖 調用此方法在「的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常子視圖定位是精細
,但如果我在progressView的
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
它的位置顯示alertView是不當
除非要鎖定應用程序,否則不必創建模態視圖。最簡單的做法是製作一個全屏視圖,例如70%透明,黑色背景。大小可以是任何你喜歡的。模態地做事的麻煩是整個應用程序停止 –
以下是您可以輕鬆完成的一個示例,它使您可以輕鬆添加後臺任務。簡單得多。 http://www.code4app.com/photo/4f67fccc6803faaa75000001_1.png –