【问题标题】:ScrollView doesn't work on iPad but works on iPhoneScrollView 不能在 iPad 上工作,但在 iPhone 上工作
【发布时间】:2016-10-17 21:42:14
【问题描述】:

我有一个滚动视图,它是完全关闭的按钮。此滚动视图适用于 iPhone,但不适用于 ipad

#define scrollViewSizeForiPad 1000 
#define scrollViewSizeForiPhone 600 
#define locationButtonSizeForiPhone 50 
#define locationButtonSizeForiPad 30

我添加了这样的按钮

lc_button.frame = CGRectMake(0, 0, buttonSize, buttonSize);
[_uiScrollForLocations addSubview:lc_button];

还有一些标签

if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
    buttonSize = buttonWidthHeightForiPad;
    lc_label.font = [UIFont systemFontOfSize:14];
    lc_label.frame = CGRectMake(3, 100, buttonSize, 20);
} else {
    buttonSize = buttonWidthHeightForiPhone;
    lc_label.font = [UIFont systemFontOfSize:9];
    lc_label.frame = CGRectMake(8, 50, buttonSize, 10);
}
[_uiScrollForLocations addSubview:lc_label];


-(void) showLocations:(NSMutableArray *)lc_array {
[self hideAllLocations];
[self addButtonToView:lc_array whichView:_uiScrollForLocations type:@"Location"];

CGSize pagesScrollViewSize = _uiScrollForLocations.frame.size;
int viewHeight;
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
    viewHeight = buttonWidthHeightForiPad;
} else {
    viewHeight = buttonWidthHeightForiPhone;
}
_uiScrollForLocations.contentSize = CGSizeMake(pagesScrollViewSize.width, viewHeight);}

【问题讨论】:

    标签: ios objective-c ipad uiscrollview


    【解决方案1】:

    这是因为 contentSize

    需要设置

    _uiScrollForLocations.alwaysBounceVertical = YES

    _uiScrollForLocations.alwaysBounceHorizontal = YES

    【讨论】:

    • 开始滚动,但它返回第一个位置,而不是停留在我想要的位置。你有办法处理他的情况吗?谢谢。
    • @kozer,需要制作更大的 contentSize
    猜你喜欢
    • 2012-01-22
    • 1970-01-01
    • 2015-03-17
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    • 2016-07-07
    • 2018-09-05
    • 1970-01-01
    相关资源
    最近更新 更多