love_loveec 2013-03-06 02:51 采纳率: 85.7%
浏览 2196

加载符号没有在button点击出现

-(IBAction)addtocontacts:(id)sender
{
    HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    HUD.labelText = NSLocalizedString(@"Saving_data", @"");

    //added my validation here
   [self performSelectorInBackground:@selector(insertDetails) withObject:nil];
}
-(void) insertDetails
{
  //save contact details in database
[HUD hide:YES];
    UIAlertView *alertview=[[UIAlertView alloc]initWithTitle:@"" message:@"Contact account details added" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alertview show];
}

我在savebutton点击添加了加载符号,但是没成功,怎么让符号出现,到了有警告信息时再消失?

  • 写回答

3条回答

  • ArcRain 2013-03-06 06:08
    关注

    performSelectorInBackground这里马上就去运行了,同时[HUD hide:YES];又让loading动画隐藏了。
    你可以试着注释掉[HUD hide:YES];
    另外,有关UI的操作,最好都不要放到Background线程里,因此performSelectorInBackground最好改为performSelector

    评论

报告相同问题?

悬赏问题

  • ¥30 软件自定义无线电该怎样使用
  • ¥15 R语言mediation包做中介分析,直接效应和间接效应都很小,为什么?
  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)