我有一个主视图为 480 x 510 的 iPhone 应用程序。当我从纵向变为横向时,我对坐标系如何变化感到有些困惑。
最初,我有一个 480x480 的内容区域,并且想在侧面添加一个按钮来调出菜单。但是,我能找到的让文字沿着应用左侧的长度运行的唯一方法是将整个应用的方向更改为横向右侧。
现在,随着横向的方向,滚动视图从左上角开始,当我真的希望它从原始方向点开始(从它处于纵向模式时),这将是左下角。但我不知道如何改变滚动视图的原始起点。我尝试了 contentOffset,但它似乎不起作用。
另一种解决方法(我可能最终会这样做)是忘记在按钮上设置标题,而只需为按钮创建一个具有垂直方向文本的图形。
if (self = [super initWithCoder:coder]) {
// Size of the scrollview
self.contentSize = CGSizeMake(480, 510);
[self setContentOffset:CGPointMake (0, -160)];
self.showsHorizontalScrollIndicator = YES;
self.showsVerticalScrollIndicator = YES;
self.alwaysBounceVertical = NO;
self.alwaysBounceHorizontal = NO;
self.bounces = YES;
self.userInteractionEnabled = YES;
self.musicGridView = [[[MusicGridView alloc] initWithCoder:coder] autorelease];
// Rectangle where I put the music grid (origin is left aligned, and down 160 pixels to account for landscape view)
self.musicGridView.frame = CGRectMake(0, 160, 480, 480);
[self addSubview: musicGridView];
self.menuButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.menuButton.frame = CGRectMake(0, 480, 480, 32);
[menuButton setTitle: @"Tap to get Menu" forState: UIControlStateNormal];
[menuButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[menuButton addTarget:self action:@selector(showMenu) forControlEvents:UIControlEventTouchUpInside];
[self addSubview: menuButton];