UIActivityIndicatorView 显示为空白
我的手机中的活动指示器遇到了这个问题。我在此方法中启动动画,然后从那里下载数据。当 numbersResponseData.length != 0
时,我重新加载表视图并调用停止动画,但我看不到活动指示器。
我有一个附件视图箭头,在加载时它会向左移动,我只是看不到指示器。
这是在 tableView:cellForRowAtIndexPath:
方法中:
if(indexPath.section == 0)
{
if ((indexPath.row == 0) && (numbersResponseData.length == 0))
{
cellActivityIndicator =
[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cellActivityIndicator startAnimating];
[cell setAccessoryView:cellActivityIndicator];
// Call ASIHTTPRequest methods to start xml download/cache process
[self setRequestString:@"Numbers.xml"];
}
//will set other cells up later
}
更新:
我在 if 语句的不同部分中添加了 UIActivityIndicator 调用,现在它将活动指示器应用于每个单元格,但现在我可以看到它们。
if(indexPath.section == 0)
{
cellActivityIndicator =
[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cellActivityIndicator startAnimating];
[cell setAccessoryView:cellActivityIndicator];
if ((indexPath.row == 0) && (numbersResponseData.length == 0))
{
cellActivityIndicator =
[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cellActivityIndicator startAnimating];
[cell setAccessoryView:cellActivityIndicator];
// Call ASIHTTPRequest methods to start xml download/cache process
[self setRequestString:@"Numbers.xml"];
}
//will set other cells up later
}
我已经调试了 .row if 语句,并且它被挑衅地调用。我只是不明白为什么它可以从一个 if 语句中工作,但不能从下一个 if 语句中工作。
I am having this issue with my activity indicator in my cell. I start the animation in this method here then download the data from there I reload the table view and call stop animating when numbersResponseData.length != 0
but I cannot see the activity indicator.
I have an accessory view arrow thingy that moves to the left when its loading I just cannot see the indicator.
This is inside the tableView:cellForRowAtIndexPath:
method:
if(indexPath.section == 0)
{
if ((indexPath.row == 0) && (numbersResponseData.length == 0))
{
cellActivityIndicator =
[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cellActivityIndicator startAnimating];
[cell setAccessoryView:cellActivityIndicator];
// Call ASIHTTPRequest methods to start xml download/cache process
[self setRequestString:@"Numbers.xml"];
}
//will set other cells up later
}
UPdate:
I added the UIActivityIndicator call inside a different part of my if statement and now it applied the activity indicator to every cell but now I can see them.
if(indexPath.section == 0)
{
cellActivityIndicator =
[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cellActivityIndicator startAnimating];
[cell setAccessoryView:cellActivityIndicator];
if ((indexPath.row == 0) && (numbersResponseData.length == 0))
{
cellActivityIndicator =
[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[cellActivityIndicator startAnimating];
[cell setAccessoryView:cellActivityIndicator];
// Call ASIHTTPRequest methods to start xml download/cache process
[self setRequestString:@"Numbers.xml"];
}
//will set other cells up later
}
I have debugged the .row if statement and its defiantly getting called.. I just don't understand why it would work from one if statement but not the next.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你的 UIActivityIndicatorView 隐藏在 UITableView 后面。转储此代码并检查您是否能够在视图中看到此指示器或不
删除使用此指示器,
i think your UIActivityIndicatorView is hiding behind the UITableView. Dump this code and check do you able to see this indicator on view or not
to remove use this,
您是从 UI 循环还是从工作线程调用此代码?如果您从工作线程调用,则需要使用performSelectorOnMainThread: 来调用UI 更改。请参考:
Are you calling this code from the UI loop, or from a worker thread? You will need to use performSelectorOnMainThread: to invoke UI changes if you're calling from a worker thread. Please refer to: