【问题标题】:How can I make image always face up?如何使图像始终朝上?
【发布时间】:2011-04-15 19:50:57
【问题描述】:

我有一张描述猴子头的图片。我希望猴子的头总是朝上。当您转动设备时,猴子的头部也会转动,但我希望尽管 iPhone 旋转,但猴子的头部不会转动(就像指南针一样)。

我该怎么做?

【问题讨论】:

  • vous devez vous rendre à chaque question que vous avez déjà demandé et cliquez sur la case à cocher par la réponse la plus appropriée à l'accepter。 Aider les gens à obtenir la reconnaissance。 Si vous n'avez pas "accepter" les réponses en cochant les gens sont moinssensitives d'aider。 Vous devez augmenter votre "accepter taux« aussi proche que que possible de 100%

标签: iphone cocoa-touch animation compass-geolocation


【解决方案1】:

如果您想在设备转动时跟随设备,您必须使用 CLLocationManager 进行跟踪。

但是,如果您只是希望猴子在用户从纵向转换为横向(以及它们的对立面)时保持直立,那么也许 UIInterfaceOrientation 可以解决问题:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return YES;
}

【讨论】:

  • 我可以了解更多关于 CLLocation 的详细信息
【解决方案2】:
  1. 要使用动画进行旋转,this link 可能会有所帮助。
  2. 要遵循设备的方向是另一回事...

可能涉及使用 CLLocationManager 的指南针 :) :

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading

或者更好,using gyroscope


请务必查看 Apple 文档,therethere 另请查看 Apple 示例代码:

【讨论】:

  • 我没有找到关于它的教程。我只是无法开始
猜你喜欢
  • 1970-01-01
  • 2021-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多