ios - Adding subviews programmatically positions them weirdly -
i have view in want add multiple subviews, when add them, positioned in positions didn't set frame. x
coordinate correct, y
quite off.
using interface builder went quite smooth, drag them in , send correct frame , origin. don't appear able set origin; expression not assignable
when try view.frame.origin = cgpointmake(x, y)
, , setting x
, y
coordinates directly gives me same error.
does happens because subviews cannot overlap programmatically without setting special attribute (that i'm missing)?
edit: views being set in initwithstyle
method of uitableviewcell.
edit 2: added code within initwithstyle
method.
// initialize images self.imageview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"image"]]; self.animageview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"animage"]]; self.anotherimageview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"anotherimage"]]; // set imageview locations self.imageview.frame = cgrectmake(0, 0, 300, 54); self.animageview.frame = cgrectmake(20, 53, 16, 52); self.anotherimageview.frame = cgrectmake(179, 43, 111, 53);
to avoid expression not assignable
, have set entire frame @ once, either using
view.frame = cgrectmake(x, y, width, height)
or
cgrect frame = self.view.frame; frame.origin.x = newx; self.view.frame = frame;
Comments
Post a Comment