添加弹出窗口以进行数据库更新

时间:2011-03-20 03:56:07

标签: iphone xcode ios

我是一名新的iphone开发者,正准备推出我的第一款应用。我有一个参考实用程序应用程序,我是在经验丰富的开发人员的帮助下开发的,用于提供从访问权限上传数据库更新到SQLite的过程。当更新发生时,我出现一个弹出窗口,提示用户是否接受数据更新。但是,如果他们接受更新,我希望在更新过程中显示一个弹出窗口。我需要做些什么才能对此代码进行广告宣传?

   if( [elementName isEqualToString:@"is_update_availableResult"] )
   {
           if([soapResults isEqualToString:@"yes"])
           {
                   soapResults = [[NSMutableString alloc] init];
                   NSString *strMessage=@"An update is available. Select OK to update or cancel to load later. Please wait while system loads data before using app. ";
                   altView=[[UIAlertView alloc] init];
                   altView.title=@"MY APP";
                   altView.delegate=self;
                   [altView addButtonWithTitle:@"OK"];
                   [altView addButtonWithTitle:@"Cancel"];
                   [altView setCancelButtonIndex:0];
                   altView.message=strMessage;
                   [altView show];

           }

1 个答案:

答案 0 :(得分:0)

使用以下代码实现数据库操作的进度指示。 在类头文件中声明UIAlertView * myAlert。

myAlert = [[UIAlertView alloc] initWithTitle:@"Updating database…" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [myAlert show];

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    indicator.center = CGPointMake(myAlert.bounds.size.width / 2, myAlert.bounds.size.height - 50);
    [indicator startAnimating];
    [myAlert addSubview:indicator];
    [indicator release];

完成数据库操作后,请关闭UIAlertView

-(void) OperationCompleted
{
    [myAlert dismissWithClickedButtonIndex:0 animated:YES];
}