SVProgressHUD在NSOperationQueue内显示警报

时间:2013-11-27 10:55:55

标签: ios

我有一个注册按钮,通过点击这个我将注册操作添加到NSOperationQueue,但我的问题是,如果用户名字段是空白警报没有出现。有人请建议我添加注册相关任务到NSOperationQueue一个正确的方法或不是

- (IBAction)Register:(UIButton *)sender {

  NSOperationQueue *queue = [NSOperationQueue new];
  NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                    selector:@selector(loadDataWithOperation)
                                                                      object:nil];
 [queue addOperation:operation];

}

- (void) loadDataWithOperation {


    if(username.text.length==0)
    { NSLog(@"loadDataWithOperation");

    [SVProgressHUD showSuccessWithStatus:@"Enter User Name"];
    }

 else

    {
      //cose for registration

    }

}

1 个答案:

答案 0 :(得分:0)

使用此代码:

if ([username.text isEqualToString:@""])
        {
          UIAlertView *alert [[UIAlertView alloc] initWithTitle:@"Message" message:@"Please fill all the fields." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

          [alert show];
        }