Reputation: 769
my problem is that I want to display the array elements in the label values using only one prototype cell but what i'm getting is this
And here is my code. Can someone please help me in this? sorry for my bad english. :)
- (void)viewDidLoad {
[super viewDidLoad];
self.imgProfilePic.layer.cornerRadius = self.imgProfilePic.bounds.size.width/2;
self.imgProfilePic.layer.masksToBounds = YES;
self.lblBadge.layer.cornerRadius = self.lblBadge.bounds.size.width/2;
self.lblBadge.layer.masksToBounds = YES;
self.userData = [NSMutableArray arrayWithObjects:@"Projects",@"Tags",@"Saved Searches",@"Filters",@"Groups",@"Users",@"Settings",@"Abouts Us", nil];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [self.userData count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *identifier = @"myCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
cell.textLabel.text = [self.userData objectAtIndex:indexPath.row];
return cell;
}
Upvotes: 0
Views: 41
Reputation: 9
If you use stoyboard and you know count of elements you can put label's into cell and use them all. But you have to set label tag:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
UILabel * caption =(UILabel*)[cell viewWithTag:(1)];
caption.text = ...
Also you can use UIimage same way.
Upvotes: 1