【问题标题】:Moving an UIView - newbie iphone sdk移动 UIView - 新手 iphone sdk
【发布时间】:2010-11-21 03:23:53
【问题描述】:

大家好...今天是我第一天破解 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;
}

我在我的 .m 文件中的 frame.origin 行收到一个错误,上面写着... lvalue required as left operand assignment。不知道我做错了什么。

任何帮助都很好,谢谢。

【问题讨论】:

    标签: iphone cocoa-touch


    【解决方案1】:

    如果你想修改 UIView 的 frame 属性,你应该这样做:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-18
      • 1970-01-01
      • 1970-01-01
      • 2016-05-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多