【问题标题】:Appcelerator IOS Module DevelopmentAppcelerator IOS模块开发
【发布时间】:2016-05-10 13:22:25
【问题描述】:

我很难为 Titanium/Appc 创建一个 IOS 模块,我正在尝试集成 https://github.com/antiguab/BAFluidView,以便我可以在钛中使用它。

我已按照模块教程进行操作,仅使用标准视图即可正常工作,但是当我尝试添加 BAFluidView 时,它不起作用。

我已经在 xcode 中包含了这些类,并且有下面的代码。

#import "ComExampleFluidView.h"
#import "TiUtils.h"
#import "BAFluidView.h"
#import "UIColor+ColorWithHex.h"

@implementation ComExampleFluidView
- (void)initializeState
{
    // Creates and keeps a reference to the view upon initialization
    square = [[UIView alloc] initWithFrame:[self frame]];

    BAFluidView *view = [[BAFluidView alloc] initWithFrame:view.frame];
    [view fillTo:@1.0];
    view.fillColor = [UIColor colorWithHex:0x397ebe];
    [view startAnimation];
    [square addSubview:view];

    [self addSubview:square];
    [super initializeState];
}
-(void)dealloc
{
    // Deallocates the view
    RELEASE_TO_NIL(square);
    [super dealloc];
}
-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
{
    // Sets the size and position of the view
    [TiUtils setView:square positionRect:bounds];
}
-(void)setColor_:(id)color
{
    // Assigns the view's background color
    square.backgroundColor = [[TiUtils colorValue:color] _color];
}
@end

头文件是

#import "TiUIView.h"
@interface ComExampleFluidView: TiUIView {
    UIView *square;
}
@end

谁能给点建议?

【问题讨论】:

    标签: ios module appcelerator appcelerator-titanium


    【解决方案1】:

    由于您试图桥接原生视图,因此您需要一些布局助手来正确处理 Titanium 布局系统。请检查ti.googlemaps 等模块,尤其是视图的initialization。此外,像setColor 这样的自定义设置器需要将颜色应用于BAFluidView,而不是UIView,因此您需要在标题中保留对它的引用。我想 ti.googlemaps 示例应该解释您正在寻找的所有概念。祝你好运!

    【讨论】:

    • 嗨,汉斯,感谢您的建议,我会看看并回来查看;)
    • 你好,你成功了吗?
    • 嗨,汉斯,不幸的是,还没有尝试让它工作,在尝试桥接原生视图时卡住了。我找不到任何信息教程或任何东西可以为我指明正确的方向,只是试图将部分 googlemap 代码模仿到我的项目中然后进行测试。那么我是否应该尝试将其应用于钛视图的正确方法,或者您是否有更好的方法可以建议?或者有什么资源可以推荐?
    • 好吧..你知道吗?我拿走了你的图书馆并为你创建了模块的核心:github.com/hansemannn/ti.fluidview。包括示例!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-20
    • 1970-01-01
    相关资源
    最近更新 更多