【发布时间】:2026-02-03 05:35:01
【问题描述】:
我是 ios 开发的新手,现在想在我的应用程序中提供一个水平滚动按钮,我不知道这是正确的方法,请告诉我如何制作它
这是我尝试以编程方式创建水平 uibutton 的代码,但它现在正在通过警告工作
未声明的选择器newView
我不知道我必须在 newview 中编写代码以使按钮使用四个以上的按钮滚动我希望所有按钮都水平滚动但我无法让我尝试使用一个按钮创建
p>这是我在视图 didload 中使用的代码
UIScrollView *scrollview =[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
scrollview.showsHorizontalScrollIndicator=YES;
scrollview.userInteractionEnabled=YES;
scrollview.scrollEnabled=YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(newView:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Excavations" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:scrollview];
scrollview.contentSize = CGSizeMake(320,960);
谁能告诉我 wt 是在我使用故事板中的 uiscorllview 和按钮时进行水平滚动的正确方法,以及如何使按钮滚动
看到很多类似link 987654321@的教程样本,我不知道让我很困惑
【问题讨论】:
标签: ios iphone objective-c button uiscrollview