2

アプリケーションで TableView のヘッダーに Image を設定しています。

Iphone 3G では問題なく動作しますが、同じコードが Iphone 5 では動作しません。非常に小さいサイズの画像のフレームのみが表示されます。

フレーム幅を増やしても画像は増えません。

これが私のコードです:

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
        CGSize result = [[UIScreen mainScreen] bounds].size;
        NSLog(@"height%f",result.height);
        if(result.height > 500){
            NSLog(@"iPhone 5");

            UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320,30)];
            UIImageView *img = [[UIImageView alloc]initWithFrame:headerView.frame];
            if(tableView == tableview1)
                    {
                img.image = [UIImage imageNamed:@"My Contacts Overlay.fw.png"];
                    }
            else if(tableView == tableview2)
                    {
                img.image = [UIImage imageNamed:@"My Contacts Overlay2.fw.png"];
                    }

            [headerView addSubview:img];
            return headerView;
        }
}

どなたかお願いします!これで私を助けますか?

4

1 に答える 1

0

headerView と img に Autoresizingmask を設定します...うまくいくことを願っています

プログラムによるマスクの自動サイズ変更 vs Interface Builder / xib / nib

于 2013-05-07T11:04:36.233 に答える