【问题标题】:UIButton not touchable - customizing from iPhone 4 to iPhone 5UIButton 不可触摸 - 从 iPhone 4 自定义到 iPhone 5
【发布时间】:2013-05-08 04:58:22
【问题描述】:

我正在开发我的应用程序以使其与 iphone 5 兼容。在以下代码中,donebutton 适用于 iphone 4,但对于 iphone5,它是不可触摸的!不知道为什么?

 float screenSizeHeight=[UIScreen mainScreen].bounds.size.height;


if(screenSizeHeight==568)
{
    UIImageView *my_image_view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Plain_Background2.png"]];
    [my_image_view setFrame:CGRectMake(0,20,320,568)];
    [self.view addSubview:my_image_view];
    [self.view sendSubviewToBack:my_image_view];

    imageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)];
    [doneButtonOutlet setFrame:CGRectMake(124,470,72,28)];
}
if(screenSizeHeight==480)
{
    UIImageView *my_image_view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Plain_Background.png"]];
    [my_image_view setFrame:CGRectMake(0,20,320,480)];
    [self.view addSubview:my_image_view];
    [self.view sendSubviewToBack:my_image_view];
    imageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 400)];
    [doneButtonOutlet setFrame:CGRectMake(124,432,72,28)];
}

【问题讨论】:

    标签: ios xcode uibutton iphone-5


    【解决方案1】:

    这是因为在 iPhone 5 中,scrollView 的高度更高,并且位于您的按钮上方。

    所以改变 UIButton 的原点 y。

        imageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)]; 
    // Here imageScrollView bottom is at 480 pixel and doneButtonOutlet origin is at 470 so either small height of scrollview or change button origin y.. 
            [doneButtonOutlet setFrame:CGRectMake(124,470,72,28)];
    

    希望对你有帮助。

    【讨论】:

    • 超级好,非常感谢。夜间工作让我发疯! :-) 我将接受答案。但我必须等 5 分钟。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    相关资源
    最近更新 更多