UI问题与ipad的kal日历?

时间:2012-01-12 12:51:23

标签: objective-c ios cocoa-touch ipad

我的iPad版Kal Calendar有UI问题。在iPad上有一个空的空间,但在iPhone上它很好。我怎样才能让它适合iPad上的框架?

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    [kal.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    [kal.view setFrame:CGRectMake(0, 0,768 ,1004)];

}

我尝试使用上面列出的代码,但它对我不起作用!

enter image description here

1 个答案:

答案 0 :(得分:13)

在KalGridView.m中你会发现这个。

const CGSize kTileSize = { 46.f, 44.f };

我将代码更改为一个属性,您可以动态地将框架设置为成语和/或方向。

在KalGridView.m

 const CGSize kTileSize = { 109.0f, 109.0f };

和KalView.m

- (void)addSubviewsToHeaderView:(UIView *)headerView

  …

  for (CGFloat xOffset = 0.f; xOffset < headerView.width; xOffset += 109.f, i = (i+1)%7) {
    CGRect weekdayFrame = CGRectMake(xOffset, 30.f, 109.f, kHeaderHeight - 29.f);
    UILabel *weekdayLabel = [[UILabel alloc] initWithFrame:weekdayFrame];
    weekdayLabel.backgroundColor = [UIColor clearColor];
    weekdayLabel.font = [UIFont boldSystemFontOfSize:10.f];
    weekdayLabel.textAlignment = UITextAlignmentCenter;
    weekdayLabel.textColor = [UIColor colorWithRed:0.3f green:0.3f blue:0.3f alpha:1.f];
    weekdayLabel.shadowColor = [UIColor whiteColor];
    weekdayLabel.shadowOffset = CGSizeMake(0.f, 1.f);
    weekdayLabel.text = [weekdayNames objectAtIndex:i];
    [headerView addSubview:weekdayLabel];
    [weekdayLabel release];
  }
}

结果:

screenshot