· 7 years ago · Mar 02, 2019, 10:10 PM
1- (id)initWithStyle:(UITableViewStyle)style
2{
3 self = [super initWithStyle:style];
4 if (self) {
5 // Custom initialization
6 }
7 return self;
8}
9
10- (void)viewDidLoad
11{
12 [super viewDidLoad];
13
14 // Uncomment the following line to preserve selection between presentations.
15 // self.clearsSelectionOnViewWillAppear = NO;
16
17 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
18 // self.navigationItem.rightBarButtonItem = self.editButtonItem;
19 myimages= [NSArray arrayWithObjects: ...//definition of array with 22 images, its sure that everyone exists and I am writing them without the .png
20
21
22
23
24}
25
26- (void)viewDidUnload
27{
28 [super viewDidUnload];
29 // Release any retained subviews of the main view.
30 // e.g. self.myOutlet = nil;
31}
32
33- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
34{
35 return (interfaceOrientation == UIInterfaceOrientationPortrait);
36}
37
38#pragma mark - Table view data source
39
40- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
41{
42#warning Potentially incomplete method implementation.
43 // Return the number of sections.
44 return 1;
45}
46
47- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
48{
49#warning Incomplete method implementation.
50 // Return the number of rows in the section.
51 return [tracksimages_closed count];
52}
53
54- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
55{
56
57 // Configure the cell...
58 //getting the identifier
59 static NSString *simpleTableIdentifier=@"SimpleTableCell";
60 //this is the identifier of the custom cell
61 SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
62 if (cell == nil)
63 {
64 NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
65 cell = [nib objectAtIndex:0];
66 }
67
68 cell.mainImage.image = [UIImage imageNamed:[myimages objectAtIndex:indexPath.row]];
69
70 return cell;
71
72}
73
74/*
75// Override to support conditional editing of the table view.
76- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
77{
78 // Return NO if you do not want the specified item to be editable.
79 return YES;
80}
81*/
82
83/*
84// Override to support editing the table view.
85- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
86{
87 if (editingStyle == UITableViewCellEditingStyleDelete) {
88 // Delete the row from the data source
89 [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
90 }
91 else if (editingStyle == UITableViewCellEditingStyleInsert) {
92 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
93 }
94}
95*/
96
97/*
98// Override to support rearranging the table view.
99- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
100{
101}
102*/
103
104/*
105// Override to support conditional rearranging of the table view.
106- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
107{
108 // Return NO if you do not want the item to be re-orderable.
109 return YES;
110}
111*/
112
113#pragma mark - Table view delegate
114
115- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
116{
117 // Navigation logic may go here. Create and push another view controller.
118 /*
119 <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
120 // ...
121 // Pass the selected object to the new view controller.
122 [self.navigationController pushViewController:detailViewController animated:YES];
123 [detailViewController release];
124 */
125}
126
127- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
128{
129 return 80;
130}
131
132@end
133
134- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
135{
136 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
137 if (self) {
138 // Initialization code
139 }
140 return self;
141}
142
143- (void)setSelected:(BOOL)selected animated:(BOOL)animated
144{
145 [super setSelected:selected animated:animated];
146
147 // Configure the view for the selected state
148}
149
150- (void)dealloc {
151 [mainImage release];
152 [super dealloc];
153}
154@end
155
156myimages= [[NSArray arrayWithObjects: @"data_1",...,nil]retain]