我在我的storyboard
中有UITableViewController
,其中每个中间有三个单元格的标签在中间。 例如,如果用户通过选择一个项目点击第一个单元标签显示另一个带有项目列表的tableview
,则返回到之前的tableView
,并且应该在标签的位置打印项目名称。在代码中启动UITalbleViewController
#import <UIKit/UIKit.h>
@interface carSelectCellTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *carMake;
@property (weak, nonatomic) IBOutlet UILabel *carModel;
@property (weak, nonatomic) IBOutlet UILabel *carRego;
@property (weak, nonatomic) IBOutlet UILabel *carYear;
//the below label are the labels in the cells.
@property (weak, nonatomic) IBOutlet UILabel *carSelected;
@property (weak, nonatomic) IBOutlet UILabel *location;
@property (weak, nonatomic) IBOutlet UILabel *service;
@end
#import "BookService.h"
#import <Parse/Parse.h>
#import "carSelectCellTableViewCell.h"
@interface BookService()
@end
@implementation BookService
@synthesize tableView;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableView.delegate = self;
self.tableView.dataSource = self;
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cell tabbed");
PFObject *temp = [customerCars objectAtIndex:indexPath.row];
NSLog(@"%@", temp.objectId);
NSString *car = temp.objectId;
UIStoryboard *dashboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *change = [dashboard instantiateViewControllerWithIdentifier:@"bookAservice"];
[self presentViewController:change animated:YES completion:nil];
static NSString *Identifier = @"carSelectedCell";
//here is where i'm calling the cell to change the label value when the selection is made. before dequeueReusableCellWithIdentifier there should be appropriate tableView Table.
carSelectCellTableViewCell *cell2 = [dequeueReusableCellWithIdentifier:Identifier];
cell2.carSelected.text = @"selcted";
}
如何以编程方式启动tableView。这样我可以将单元格标签值更改为所选项目。