2010-11-21 39 views
1

嘿,大家好...今天是我第一天在iPhone SDK上砍掉。有一個爆炸,但有一個快速的問題。移動一個UIView - 新手iphone sdk

我想通過從滑塊發送信息動態地在屏幕上移動UIView。我的滑塊工作正常,但我似乎無法弄清楚如何讓UIView移動。

我.h文件中...


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

我的.m文件...


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

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

我上frame.origin行的錯誤在我的.m文件,說。左值操作數賦值需要左值。不知道我做錯了什麼。

任何幫助是偉大的,謝謝。

alt text

回答

2

如果要修改一個UIView的框架財產,則應按照以下操作步驟:

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

驚人的,非常感謝紅牛。 – barry 2010-11-21 03:44:17

+0

不客氣。 – AechoLiu 2010-11-21 07:44:26