【问题标题】:Add UIButtons to a ScrollView将 UIButtons 添加到 ScrollView
【发布时间】:2011-05-10 16:10:34
【问题描述】:

我想在一个 ScrollView 框中显示 5 个按钮,但不幸的是我编写的代码对我的 UIButtons 没有影响(我无法向上或向下滚动,你能告诉我为什么吗?

感谢您的帮助,我花了很多时间在这上面(Rookie),但我仍然找不到解决方案...

我的代码:

FirstViewController.h:

#import <UIKit/UIKit.h>


@interface FirstViewController : UIViewController <UIScrollViewDelegate> {
IBOutlet UIScrollView *scroll;
UIButton *button;
UIButton *button2;
UIButton *button3;
}

@property (nonatomic, retain) IBOutlet UIButton *button;
@property (nonatomic, retain) IBOutlet UIButton *button2;
@property (nonatomic, retain) IBOutlet UIButton *button3;
@property(nonatomic,retain) IBOutlet UIScrollView *scroll;

@end

FirstViewController.m:

#import "FirstViewController.h"

@implementation FirstViewController
@synthesize button;
@synthesize button2;
@synthesize button3;
@synthesize scroll;


- (IBAction)goToViewTwo {
        }

- (void)viewDidload {
    [super viewDidLoad];
    [scroll setScrollEnabled:YES];
    [scroll setContentSize:CGSizeMake (500, 1000)];
}

- (void)dealloc {
    [super dealloc];
    [button release];
    [scroll release];
}                                      
@end

FirstView.xib 中的层次结构:

View
  Action Sheet
  Text View
  ScrollView
    Button
    Button
    Button

关于奥特莱斯:

  • Scrollview 通过“Scroll”链接到文件所有者
  • 视图作为“视图”链接到文件的所有者

【问题讨论】:

    标签: ios uiscrollview uibutton


    【解决方案1】:

    我想您正在 Interface Builder 中实现滚动,并且该应用程序适用于 iPad(适用于 contentSize)。看看你在 IB 和代码中是否有相同的配置,尤其是[scroll setScrollEnabled:YES];

    【讨论】:

    猜你喜欢
    • 2010-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多