3

ユーザーが iPhone 5 を使用している場合、カスタム ボタンのサイズを大きくしたいと考えています。

これは私の.mファイルにあるものです

//.m File
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        int varWidth = 228;
    }
    if(result.height == 568)
    {
        int varWidth = 272;
    }
}

....

[newButton setFrame:CGRectMake(8.0, 40.0, 228, 80.0)];

しかし、私はこのようなものが欲しい:

[newButton setFrame:CGRectMake(8.0, 40.0, varWidth, 80.0)];
4

3 に答える 3

4

あなたはvarWidthその範囲外で使用しています。

int varWidth;

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    CGSize result = [[UIScreen mainScreen] bounds].size;
    if(result.height == 480)
    {
        varWidth = 228;
    }
    if(result.height == 568)
    {
        varWidth = 272;
    }
}

....

[newButton setFrame:CGRectMake(8.0, 40.0, varWidth, 80.0)];
于 2013-04-06T07:39:33.487 に答える