PanoramaGL在IOS的使用

PanoramaGL在iOS的使用并不复杂,尽管项目较旧,需要处理ARC问题。通过禁用ARC或针对个别文件添加-fno-objc-arc,可以解决编译错误。参考相关资源,如CodeProject的文章和Google的UserGuide,可以成功集成并理解关键文件PLConstants.h中的参数设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

其实,对于普通基本的使用来说,PanoramaGL不难。

按照Google上的步骤,很简单。其中注意一下几点:

因为,这个项目是12年更新的,所以没有使用ARC,如果,你引用了它的库,你会发现ARC错误,即使你全部加上-fno-objc-arc,你也会发现**变量的错误,网上有改正的方法,但是有的地方,改了还是报错,而且许多地方都要更改(**,-fno-objc-arc),所以,我选择建立工程后,把工程修改为不适用ARC,对自己新建的文件修改,添加-f-objc-arc,使用ARC。这样即使报错,双击fix一下就编译通过了。

以下是我的代码。

.h文件

@interface ViewController : UIViewController  <PLViewDelegate>//热点代理
{
@private
    PLView *plView;
}
.m文件

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    plView = (PLView *)self.view;
    plView.delegate = self;
    //开启加速
    plView.isAccelerometerEnabled = YES;
    //水平 加速
    plView.isAccelerometerLeftRightEnabled = YES;
    //灵敏度
    plView.accelerometerSensitivity = kAccelerometerSensitivityMinValue;
    /*
     #define kDefaultAccelerometerSensitivity	7.0f
     #define kDefaultAccelerometerInterval		1.0f/60.0f
     #define kAccelerometerSensitivityMinValue	1.0f
     #define kAccelerometerSensitivityMaxValue	10.0f
     #define kAccelerometerMultiplyFactor		100.0f
     */
    //刷新时间间隔 秒[NSTimeInterval
    plView.accelerometerInterval = 0.01f ;
    [self _loadView];

- (void)_loadView
{
    //添加全景图片
    NSObject<PLIPanorama> *panorama = [PLSphericalPanorama panorama];
    [(PLSphericalPanorama *)panorama setTexture:[PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"3" ofType:@"jpg"]]]];
    
    //Add a hotspot
    //添加热点
    PLTexture *hotspotTexture = [PLTexture textureWithImage:[PLImage imageWithPath:[[NSBundle mainBundle] pathForResource:@"hotspot" ofType:@"png"]]];
    PLHotspot *hotspot = [PLHotspot hotspotWithId:1 texture:hotspotTexture atv:0.10f ath:0.10f width:0.08f height:0.08f];
    //width height 热点大小 atv上正数下负数 ath 位置右边正数 左边负数
    [panorama addHotspot:hotspot];
    
    PLHotspot *hotspot1 = [PLHotspot hotspotWithId:2 texture:hotspotTexture atv:-13.1f ath:55.10f width:0.08f height:0.08f];
    [panorama addHotspot:hotspot1];
    
    [plView setPanorama:panorama];
}

//Hotspot event
//热点事件
- (void)view:(UIView<PLIView> *)pView didClickHotspot:(PLHotspot *)hotspot screenPoint:(CGPoint)point scene3DPoint:(PLPosition)position
{
    NSLog(@"点击了热点%d",(int)hotspot.identifier);
}
热点的作用为:随着图片转动。所以,你想标示一个图片上的固定点,你就需要热点了。
最后给出两个参考的网址

http://www.codeproject.com/Articles/60635/Panorama-iPod-Touch-iPhone 许多博客都是翻译的这个

https://code.google.com/p/panoramagl/wiki/UserGuide  可以根据这个建立工程

一个重要的文件

PLConstants.h许多不懂的参数可以到这来看看默认的设置


转载是请保留:来自http://blog.youkuaiyun.com/ralbatr

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值