【发布时间】:2013-11-09 09:56:32
【问题描述】:
我使用以下代码设置按钮。它工作正常,但在可滚动的窗口中设置它时,按钮仍固定在屏幕上,视图在其后面滚动。 如何使按钮跟随滚动。 如果我使用 IB 设置一个按钮,它会跟随滚动。这就是我想要的,但现在我希望使用编程方法。
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Button" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
【问题讨论】:
-
将按钮添加到 UIScrollView no to self.view.
标签: ios uiscrollview uibutton