【发布时间】:2014-08-27 14:04:59
【问题描述】:
所以我试图在从另一个 tableviewController 推送的 UIViewController 中填充一个 tableview。我知道我必须写一个 if 语句,但我遇到了麻烦......重申一下,我想我的问题是如何在从 tableViewController 推送的详细视图控制器中填充 tableView?请参阅下面的代码以供参考,如果我没有提供所需的一切,我提前道歉,我可能完全走错了方向......
感谢您的所有意见!
/* DetaiLViewController.m file */
#import "DetaiViewController.h"
#import "RecommendationsCell.h"
/* .......... */
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.title = _DetailModal[0];
/*WHAT IS THE IF STATEMENT ???!! */
if ([self.navigationItem.title isEqualToString: @"London, United Kingdom"]) {
DetailedImages.image = /* HERE IS AN ARRAY OF London IMAGES to DISPLAY ON DETAILEDVIEWCONTROLLER */
IF....
DetailedImages.image = /* HERE IS AN ARRAY OF LONDON IMAGES to DISPLAY ON DETAILEDVIEWCONTROLLER */
IF....
DetailedImages.image = /* HERE IS AN ARRAY OF BERLIN IMAGES to DISPLAY ON DETAILEDVIEWCONTROLLER */
IF...
DetailedImages.image = /* HERE IS AN ARRAY OF PERTH IMAGES to DISPLAY ON DETAILEDVIEWCONTROLLER */
IF...
THE REMAINING ARRAYS FOR EACH CELL FROM TABLEVIEWCONTROLLER ETC.......
];
}
/* HERE IS ARRAY FROM TABLEVIEWCONTROLLER THAT PUSHES TO DETAILEDVIEWCONTROLLER */
/* _Images = @[@"london.jpeg",
@"berlin.jpeg",
@"perth.jpeg",
@"beijing.jpeg",
@"Madrid-26512.jpg",
@"barcelona.jpeg",
@"norway1_2141015b.jpg",
@"sweden.jpeg",]; */
/* HERE IS ARRAY FROM TABLEVIEWCONTROLLER THAT PUSHES TO DETAILEDVIEWCONTROLLER */
/* _Title = @[@"London, United Kingdom",
@"Berlin, Germany",
@"Perth, Australia",
@"Beijing, China",
@"Madrid, Spain",
@"Barcelona, Spain",
@"Oslo, Norway",
@"Denmark, Sweden",]; */
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return _Title.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"RecommendationsCell";
RecommendationsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
int row = [indexPath row];
cell.TitleLabel.text = _Title[row];
//cell.DescriptionLabel.text = _Description[row];
cell.ThumbImage.image = [UIImage imageNamed:_Images[row]];
return cell;
}
/* DetailedViewController.h file */
@interface DetaiViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UIImageView *DetailedImages;
}
//@property (nonatomic, strong) NSArray *Description;
@property (nonatomic, strong) NSArray *Title;
@property (nonatomic, strong) NSArray *Images;
@property (strong, nonatomic) NSArray *DetailModal;
@end
/* DetailedViewController Cell.h file */
@interface RecommendationsCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong, nonatomic) IBOutlet UIImageView *ThumbImage;
//@property (strong, nonatomic) IBOutlet UILabel *DescriptionLabel;
@property (strong, nonatomic) IBOutlet UIImageView *DetailedImages;
@end
【问题讨论】:
标签: objective-c uitableview ios7 xcode5