2016-04-17 13 views
2

質問の主な目的に移る前に、KASlideShowはgithubのライブラリです。私はこのライブラリを使用して画像のスライドショーを表示しています。カスタムセルを実装する方法をたくさん検索した結果、次のような結果が得られました。Is it possible to add UITableView within a UITableViewCellここで私が使用しているコードは次のとおりです。UITableView内のセル内にKASlideShowを追加する方法

#import "HomeTableViewController.h" 
#import "KASlideShow.h" 
#import "CustomTableViewCell.h" 
@interface HomeTableViewController() 
@property (strong,nonatomic) IBOutlet KASlideShow * slideshow; 

@end 

@implementation HomeTableViewController 

- (void)viewDidLoad { 
[super viewDidLoad]; 



} 

    - (void)didReceiveMemoryWarning { 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 








-(UITableViewCell *)tableView:(UITableView *)tableView  cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    CustomTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"SlideShowCell"]; 
    if(cell == nil) 
    { 
     cell = [[CustomTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SlideShowCell"]; 

     } 


    [_slideshow setDelay:5]; // Delay between transitions 
    [_slideshow setTransitionDuration:5]; // Transition duration 
    [_slideshow setTransitionType:KASlideShowTransitionFade]; // Choose a transition type (fade or slide) 
    [_slideshow setImagesContentMode:UIViewContentModeScaleAspectFill]; // Choose a content mode for images to display 
    [_slideshow addImagesFromResources:@[@"adidas.jpg",@"adidas_neo.jpeg"]]; // Add images from resources 
     [_slideshow addGesture:KASlideShowGestureTap]; // Gesture to go previous/next directly on the image 
[_slideshow start]; 
     return cell; 
    } 


@end 







    #import <UIKit/UIKit.h> 
    #import "KASlideShow.h" 
    @interface CustomTableViewCell : UITableViewCell 
    @property (nonatomic) IBOutlet KASlideShow *slideshow; 



    #import "CustomTableViewCell.h" 
    #import "KASlideShow.h" 
    @implementation CustomTableViewCell 

    - (void)awakeFromNib { 
    [super awakeFromNib]; 
// Initialization code 
} 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated { 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 



- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 
{ 
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 
    if (self) { 
     // Initialization code 


    } 
    return self; 
} 

@end 





    @end 

KASlideShowは、私は間違って何かがあると知っているが、私は、それはそれを修正する場所を知ることができないのですUITableViewCellの内側に表示されることはありません。

+0

私はKASlideShowの割り当てが表示されません。また、githubレポはデリゲートを設定する必要があると述べています。削除セットはどこですか? – fsb

+0

@fbara私はデリゲートを追加しようとしましたが、何も変更しませんでした。私はKASlideShowに何も変更しないために割り当てようとしました。 –

+0

あなたの質問を新しいコードで更新できますか? – fsb

答えて

1

なぜKASlideShowをurのヘッダービューに追加しないでくださいUITableViewControllerheaderViewとそれに1より多くのビューを追加し、KASlideShow

のそれをサブクラスが、あなたのコードは次のようになりますViewDidLoad

KASlideShow設定を追加し、その後、このビューで

をごIBOutletスライドショーを接続することを最初に作成しますコード

#import "SlideShowTableViewController.h" 
#import "KASlideShow.h" 

@interface SlideShowTableViewController() 
@property (strong,nonatomic) IBOutlet KASlideShow * slideShow; 
@end 

@implementation SlideShowTableViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Do any additional setup after loading the view, typically from a nib. 
    [self.slideShow setDelay:5]; // Delay between transitions 
    [self.slideShow setTransitionDuration:5]; // Transition duration 
    [self.slideShow setTransitionType:KASlideShowTransitionFade]; // Choose a transition type (fade or slide) 
    [self.slideShow setImagesContentMode:UIViewContentModeScaleAspectFill]; // Choose a content mode for images to display 
    [self.slideShow addImagesFromResources:@[@"adidas.jpg",@"adidas_neo.jpeg"]]; // Add images from resources 
    [self.slideShow addGesture:KASlideShowGestureTap]; // Gesture to go previous/next directly on the image 
    [self.slideShow start]; 

} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 0; // <<-- set your sections count 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 0; // <<-- set your rows count in section 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath]; 

    // Configure the cell... 

    return cell; 
} 

のようになります。

and your Interface Builder should look like

関連する問題