UIButton不可触摸 - 从iPhone 4到iPhone 5进行定制

cas*_*las 0 xcode uibutton ios iphone-5

我在我的应用程序的工作做出iphone 5在下面的代码,为iPhone 4 donebutton工程兼容,但是当涉及到的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)];
}
Run Code Online (Sandbox Code Playgroud)

Nis*_*agi 9

这是因为在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)];
Run Code Online (Sandbox Code Playgroud)

希望它能帮到你.