开发者

Moving an UIView - newbie iphone sdk

Hey guys... today is my first day hacking away on the iphone SDK. Having a blast but have a quick question.

I'm trying to move an UIView around the screen dynamically by sending it information from a slider. My slider is working fine but I cant seem to figure out how to get the UIView to move.

My开发者_运维问答 .h file...


@interface Slider_BallViewController : UIViewController 
{
   IBOutlet UISlider *theslider;
   IBOutlet UITextField *ytext;
   IBOutlet UIView *theball;
}
- (IBAction)moveVert:(id)sender;

My .m file...


- (IBAction)moveVert:(id)sender
{
 int progressAsInt = (int)(theslider.value);
 NSString *newText = [[NSString alloc] initWithFormat:@"%d", progressAsInt];
 ytext.text = newText;

 theball.frame.origin.y += progressAsInt;
}

I get an error on the frame.origin line in my .m file that says... lvalue required as left operand assignment. Not sure what im doing wrong.

Any help is great, thanks.

Moving an UIView - newbie iphone sdk


If you want to modify a UIView's frame property, you should do it by following:

CGRect curFrame = theball.frame;
curFrame.origin.y += progressAsInt;
theball.frame = curFrame;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜