2013-03-12 90 views
1

我想在我的Xamarin for iOS项目中使用iOS库iCarousel。我在XCode中创建了静态库并将其添加到Xamarin iOS绑定项目中。试图从lib.a文件中定义输出。但是我对Objective-C没有任何经验,所以我在iOS绑定项目(可以在我的目标项目中用作dll)中声明导出时遇到了困难。 我试图使用monotouch-binding-generator来生成所需的声明,但编译iOS绑定项目后出现很多错误。这是我在C#上的声明。如何在Xamarin.iOS项目中使用iCarousel

[BaseType (typeof (UIView))] 
interface iCarousel { 
    [Export ("id<iCarouselDelegate>")] 
    IBOutlet Id<iCarouselDelegate> { get; set; } 

    [Export ("type")] 
    iCarouselType Type { get; set; } 

    [Export ("perspective")] 
    float Perspective { get; set; } 

    [Export ("decelerationRate")] 
    float DecelerationRate { get; set; } 

    [Export ("scrollSpeed")] 
    float ScrollSpeed { get; set; } 

    [Export ("bounceDistance")] 
    float BounceDistance { get; set; } 

    [Export ("scrollEnabled")] 
    bool ScrollEnabled { get; set; } 

    [Export ("bounces")] 
    bool Bounces { get; set; } 

    [Export ("scrollOffset")] 
    float ScrollOffset { get; set; } 

    [Export ("offsetMultiplier")] 
    float OffsetMultiplier { get; } 

    [Export ("contentOffset")] 
    SizeF ContentOffset { get; set; } 

    [Export ("viewpointOffset")] 
    SizeF ViewpointOffset { get; set; } 

    [Export ("numberOfItems")] 
    int NumberOfItems { get; } 

    [Export ("numberOfPlaceholders")] 
    int NumberOfPlaceholders { get; } 

    [Export ("currentItemIndex")] 
    int CurrentItemIndex { get; set; } 

    [Export ("currentItemView")] 
    UIView CurrentItemView { get; } 

    [Export ("indexesForVisibleItems")] 
    NSArray IndexesForVisibleItems { get; } 

    [Export ("numberOfVisibleItems")] 
    int NumberOfVisibleItems { get; } 

    [Export ("visibleItemViews")] 
    NSArray VisibleItemViews { get; } 

    [Export ("itemWidth")] 
    float ItemWidth { get; } 

    [Export ("contentView")] 
    UIView ContentView { get; } 

    [Export ("toggle")] 
    float Toggle { get; } 

    [Export ("stopAtItemBoundary")] 
    bool StopAtItemBoundary { get; set; } 

    [Export ("scrollToItemBoundary")] 
    bool ScrollToItemBoundary { get; set; } 

    [Export ("useDisplayLink")] 
    bool UseDisplayLink { get; set; } 

    [Export ("vertical")] 
    bool Vertical { get; set; } 

    [Export ("ignorePerpendicularSwipes")] 
    bool IgnorePerpendicularSwipes { get; set; } 

    [Export ("centerItemWhenSelected")] 
    bool CenterItemWhenSelected { get; set; } 

    [Export ("IBOutletid<iCarouselDataSource>dataSource")] 
    nonatomic, ah_weak IBOutletid<iCarouselDataSource>dataSource(); 

    [Export ("scrollByOffset:duration:")] 
    void ScrollByOffsetduration (float offset, double duration); 

    [Export ("scrollToOffset:duration:")] 
    void ScrollToOffsetduration (float offset, double duration); 

    [Export ("scrollByNumberOfItems:duration:")] 
    void ScrollByNumberOfItemsduration (int itemCount, double duration); 

    [Export ("scrollToItemAtIndex:duration:")] 
    void ScrollToItemAtIndexduration (int index, double duration); 

    [Export ("scrollToItemAtIndex:animated:")] 
    void ScrollToItemAtIndexanimated (int index, bool animated); 

    [Export ("removeItemAtIndex:animated:")] 
    void RemoveItemAtIndexanimated (int index, bool animated); 

    [Export ("insertItemAtIndex:animated:")] 
    void InsertItemAtIndexanimated (int index, bool animated); 

    [Export ("reloadItemAtIndex:animated:")] 
    void ReloadItemAtIndexanimated (int index, bool animated); 

    [Export ("itemViewAtIndex:")] 
    UIView ItemViewAtIndex (int index); 

    [Export ("indexOfItemView:")] 
    int IndexOfItemView (UIView view); 

    [Export ("indexOfItemViewOrSubview:")] 
    int IndexOfItemViewOrSubview (UIView view); 

    [Export ("offsetForItemAtIndex:")] 
    float OffsetForItemAtIndex (int index); 

    [Export ("reloadData")] 
    void ReloadData(); 

} 

[BaseType (typeof())] 
[Model] 
interface iCarouselDataSource { 
    [Abstract] 
    [Export ("numberOfItemsInCarousel:")] 
    uint NumberOfItemsInCarousel (iCarousel carousel); 

    [Abstract] 
    [Export ("carousel:viewForItemAtIndex:reusingView:")] 
    UIView CarouselviewForItemAtIndexreusingView (iCarousel carousel, uint index, UIView view); 

    [Abstract] 
    [Export ("numberOfPlaceholdersInCarousel:")] 
    uint NumberOfPlaceholdersInCarousel (iCarousel carousel); 

    [Abstract] 
    [Export ("carousel:placeholderViewAtIndex:reusingView:")] 
    UIView CarouselplaceholderViewAtIndexreusingView (iCarousel carousel, uint index, UIView view); 

    [Abstract] 
    [Export ("numberOfVisibleItemsInCarousel:")] 
    uint NumberOfVisibleItemsInCarousel (iCarousel carousel); 

} 

[BaseType (typeof())] 
[Model] 
interface iCarouselDelegate { 
    [Export ("carouselWillBeginScrollingAnimation:")] 
    void CarouselWillBeginScrollingAnimation (iCarousel carousel); 

    [Export ("carouselDidEndScrollingAnimation:")] 
    void CarouselDidEndScrollingAnimation (iCarousel carousel); 

    [Export ("carouselDidScroll:")] 
    void CarouselDidScroll (iCarousel carousel); 

    [Export ("carouselCurrentItemIndexUpdated:")] 
    void CarouselCurrentItemIndexUpdated (iCarousel carousel); 

    [Export ("carouselWillBeginDragging:")] 
    void CarouselWillBeginDragging (iCarousel carousel); 

    [Export ("carouselDidEndDragging:willDecelerate:")] 
    void CarouselDidEndDraggingwillDecelerate (iCarousel carousel, bool decelerate); 

    [Export ("carouselWillBeginDecelerating:")] 
    void CarouselWillBeginDecelerating (iCarousel carousel); 

    [Export ("carouselDidEndDecelerating:")] 
    void CarouselDidEndDecelerating (iCarousel carousel); 

    [Export ("carousel:itemTransformForOffset:baseTransform:")] 
    CATransform3D CarouselitemTransformForOffsetbaseTransform (iCarousel carousel, float offset, CATransform3D transform); 

    [Export ("carousel:valueForOption:withDefault:")] 
    float CarouselvalueForOptionwithDefault (iCarousel carousel, iCarouselOption option, float value); 

    [Export ("carousel:shouldSelectItemAtIndex:")] 
    bool CarouselshouldSelectItemAtIndex (iCarousel carousel, int index); 

    [Export ("carousel:didSelectItemAtIndex:")] 
    void CarouseldidSelectItemAtIndex (iCarousel carousel, int index); 

    [Export ("carouselShouldWrap:__attribute__((deprecated))")] 
    bool CarouselShouldWrap__attribute__((deprecated)) (iCarousel carousel, (deprecated)); 

    [Export ("carouselItemWidth:__attribute__((deprecated))")] 
    float CarouselItemWidth__attribute__((deprecated)) (iCarousel carousel, (deprecated)); 

    [Export ("carouselOffsetMultiplier:__attribute__((deprecated))")] 
    float CarouselOffsetMultiplier__attribute__((deprecated)) (iCarousel carousel, (deprecated)); 

    [Export ("carousel:itemAlphaForOffset:__attribute__((deprecated))")] 
    float CarouselitemAlphaForOffset__attribute__((deprecated)) (iCarousel carousel, float offset, (deprecated)); 

    [Export ("carousel:valueForTransformOption:withDefault:__attribute__((deprecated))")] 
    float CarouselvalueForTransformOptionwithDefault__attribute__((deprecated)) (iCarousel carousel, iCarouselOption option, float value, (deprecated)); 

} 

如何修复错误并在我的Xamarin.iOS项目中使用iCarousel?这是我与Xamarin的第一个项目,如果问题很蠢,抱歉。

谢谢。

+0

你正在得到什么错误? – Blounty 2013-03-12 10:49:10

回答

2

比不上那些看起来错误:

[Export ("id<iCarouselDelegate>")] 
IBOutlet Id<iCarouselDelegate> { get; set; } 

[...] 

[Export ("IBOutletid<iCarouselDataSource>dataSource")] 
nonatomic, ah_weak IBOutletid<iCarouselDataSource>dataSource(); 

[...] 


[Export ("carouselShouldWrap:__attribute__((deprecated))")] 
bool CarouselShouldWrap__attribute__((deprecated)) (iCarousel carousel, (deprecated)); 

[Export ("carouselItemWidth:__attribute__((deprecated))")] 
float CarouselItemWidth__attribute__((deprecated)) (iCarousel carousel, (deprecated)); 

[Export ("carouselOffsetMultiplier:__attribute__((deprecated))")] 
float CarouselOffsetMultiplier__attribute__((deprecated)) (iCarousel carousel, (deprecated)); 

[Export ("carousel:itemAlphaForOffset:__attribute__((deprecated))")] 
float CarouselitemAlphaForOffset__attribute__((deprecated)) (iCarousel carousel, float offset, (deprecated)); 

[Export ("carousel:valueForTransformOption:withDefault:__attribute__((deprecated))")] 
float CarouselvalueForTransformOptionwithDefault__attribute__((deprecated)) (iCarousel carousel, iCarouselOption option, float value, (deprecated)); 

对于弃用的,删除它们,你将不再需要他们。对于其他两个,首先评论他们,然后解决它们。

还有那还有:

[BaseType (typeof())] 
[Model] 
interface iCarouselDelegate { 

委托通常是[BaseType (typeof (NSObject)]

总之,具有发电机帮助您上手,但从来没有期望它做所有的工作适合你。不要做经济不读this并知道一点关于Obj-C

相关问题