2014-01-24 37 views
0

我有一个从右侧的幻灯片菜单,我想定制有图标,而不是文本标签。iOS的幻灯片菜单与图像

我有SlideNavigationController.m和SlideNavigationController.h

在MenuViewController.h我有:

#import <UIKit/UIKit.h> 
#import "SlideNavigationController.h" 

@interface MenuViewController : UIViewController <UITableViewDelegate> 

@property (nonatomic, strong) NSString *cellIdentifier; 

@end 

在MenuViewController.m我有:

#import "MenuViewController.h" 

@implementation MenuViewController 
@synthesize cellIdentifier; 



#pragma mark - UITableView Delegate & Datasrouce - 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection (NSInteger)section 
{ 
return 3; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier]; 


switch (indexPath.row) 
{ 
    case 0: 
     cell.imageView.image = [UIImage imageNamed:@"Maps-icon.png"]; 
     break; 

    case 1: 
     cell.textLabel.text = @"Yellow"; 
     break; 

    case 2: 
     cell.textLabel.text = @"Orange"; 
     break; 



} 

return cell; 
} 

对于每个情况 (例如,案例0: cell.imageView.image = [UIImage imageNamed:@“Maps-icon.png”]; 我想将图像放在单元格的最右侧,因为这是幻灯片动画中显示的内容。我该如何改变图像的位置?

在此先感谢。

+0

我面临同样的问题;你能告诉我你是如何解决这个问题的吗?谢谢 – Sonic

回答

0

你只是想自定义一个UITableViewCell。互联网上有大量的教程介绍如何做到这一点。

http://mobile.tutsplus.com/tutorials/iphone/customizing-uitableview-cell/ https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TableView_iPhone/TableViewCells/TableViewCells.html

此外,你可能最好使用一个数组来保存你的表视图单元中的数据,而不是一个switch语句。

+0

谢谢,这些链接让我有些非常有趣的教程! – user3225664