ios - UIActivityIndicatorView Inside TableView Cell -
i'm trying add spinner button have positioned in tableviewcell. problem spinner showing outside tableviewcell.
this how implemeneted code inside cellforrowatindexpath
myspinner = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylegray]; [myspinner setcenter:cell.like.center]; [cell.like addsubview:myspinner];
and when click using sender.tag
[myspinner startanimating];
problem spinner working not wanted. it's showing outside cell.
update
with matt
's answer did work. changed code below. inside selector action. -(void) likeclicked:(uibutton*)sender
uiactivityindicatorview *myspinner = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylegray]; [myspinner setcenter: cgpointmake(cgrectgetmidx(sender.bounds), cgrectgetmidy(sender.bounds))]; [sender addsubview:myspinner]; [myspinner startanimating];
code of form:
[myspinner setcenter:cell.like.center];
...is never right. reason myspinner.center
in superview's coordinates — is, in cell.like
coordinates. cell.like.center
in its superview's coordinates. thus, comparing apples oranges: setting point in terms of point lives in different coordinate system. can work accident.
what want set myspinner.center
center of superview's bounds. values in same coordinate system (here, cell.like
's coordinate system).
[myspinner setcenter: cgpointmake(cgrectgetmidx(cell.like.bounds), cgrectgetmidy(cell.like.bounds))];
Comments
Post a Comment