的iOS开始活动的指标只有1排
我简单的tableview也是每一个细胞都得到活动的指标,但是当我点击列按钮字母键得到0和指标阿尔法获得1这样的iOS开始活动的指标只有1排
if (webserviceRunningValueInt == 1)
{
cell.unBlockUserButtonOutlet.alpha = 0;
cell.waitIndicator.alpha = 1;
[cell.waitIndicator startAnimating];
}
else
{
cell.waitIndicator.alpha = 0;
[cell.waitIndicator stopAnimating];
cell.unBlockUserButtonOutlet.alpha = 1;
}
这部分代码工作,但活动的指标开始上所有的行:)动画如何设置这个过程只有1排
希望我正确认识你的问题:你想点击一个单元格,并有一个活动的指标开始动画?
我个人并不具有对所有的人的活动的指标,然后隐藏和暴露打扰他们,这使得它有点痛的启动和停止的正确指标。
我如何在其他应用程序做它是一个指标在didSelectRow阶段添加到细胞,我们可以知道我们点击了哪个小区,并立即添加单元格:
- (void)tableView:(UITableView *)tableView_ didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView_ reloadData];
// This code will create and add an activity indicator
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
UITableViewCell * cell = [tableView_ cellForRowAtIndexPath:indexPath];
cell.accessoryView = activityIndicator;
[activityIndicator startAnimating];
[tableView_ deselectRowAtIndexPath:indexPath animated:YES];
}
整洁件事这个代码是因为我们在创建单元格时不添加活动指示器意味着我们可以通过刷新tableView来摆脱指示器。在这种情况下,每当我们点击我们摆脱了以前的指标,并添加一个新的。
希望这有助于有点
编辑:如果你想这来自小区按下一个按钮(感谢弗拉基米尔此answer)
这是一次非常简单,可以使用代码发生以上。
[button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
这将使我们能够找出当按钮被窃听
- (void)checkButtonTapped:(id)sender {
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];
// Now we have the indexPath of the cell clicked so we can use the previous code again
[tableView_ reloadData];
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
UITableViewCell * cell = [tableView_ cellForRowAtIndexPath:indexPath];
cell.accessoryView = activityIndicator;
[activityIndicator startAnimating];
}
Actullay我得到活动指标,当我按下按钮活动指标工作,但如果我有20行,所有指标工作:)我只是想工作的只有1哪一行按下 – 2015-02-05 22:55:14
当我按下按钮指示灯工作'webserviceRunningValueInt = 1' – 2015-02-05 22:56:39
所以这个代码将一个活动的指标加起来也只有按排,一旦另一行被按下,然后它会消失,并出现在新行被按下。它是愿意尝试这样只是把它复制到你的项目并进行试用 – 2015-02-05 22:56:56
哪里是这段代码被称为:
创建单元格时添加一个目标的按钮? – Stonz2 2015-02-05 20:04:57
In; ' - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { }' – 2015-02-05 20:22:28