Ios UIActivityIndicatorView表格视图单元格内部视图
我正在尝试将微调器添加到我在tableViewCell中定位的Like按钮。但问题是spinner显示在tableViewCell之外 这就是我在Ios UIActivityIndicatorView表格视图单元格内部视图,ios,objective-c,uitableview,uiactivityindicatorview,Ios,Objective C,Uitableview,Uiactivityindicatorview,我正在尝试将微调器添加到我在tableViewCell中定位的Like按钮。但问题是spinner显示在tableViewCell之外 这就是我在cellforrowatinexpath myspinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; [myspinner setCenter:cell.like.center]; [cel
cellforrowatinexpath
myspinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[myspinner setCenter:cell.like.center];
[cell.like addSubview:myspinner];
当我单击usingsender.tag
[myspinner startAnimating];
问题是旋转器工作,但不是我想要的。就在牢房外面
更新
马特的回答确实有效。
我还修改了我的代码,如下所示。内部选择器操作<代码>-(无效)如勾选:(UIButton*)发件人
UIActivityIndicatorView *myspinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[myspinner setCenter: CGPointMake(CGRectGetMidX(sender.bounds),
CGRectGetMidY(sender.bounds))];
[sender addSubview:myspinner];
[myspinner startAnimating];
本表格编号:
[myspinner setCenter:cell.like.center];
…永远都不对。原因是myspinner.center
位于其superview的坐标中,即位于cell.like
坐标中。但是cell.like.center
位于其superview的坐标中。因此,你正在比较苹果和桔子:你正在设置一个点,另一个点位于一个完全不同的坐标系中。那只能是偶然的
您要做的是将myspinner.center设置为其superview边界的中心。这些值位于同一坐标系中(此处为单元格,类似于的坐标系)
或者您可能希望使用单元格的内容视图来获取单元格的中心
[myspinner setCenter:cell.contentview.center];
这也行。谢谢,它确实行得通。而不是使用cell.like.bounds。
当我单击like按钮时,我在我的操作选择器中使用了sender.bounds
。当然,听起来不错。关键是要理解坐标系的本质。是的,我明白了。再次感谢。:)
[myspinner setCenter:cell.contentview.center];