изучал цель C только пару дней и в настоящее время озадачен таблицами / UITableView и т. Д. Я создал таблицу, в которой перечислены 6 имен, которые я прочитал, как установить аватар (изображение для слева от текста) до 1 изображения, однако я пытался установить каждое отдельное изображение с помощью массива. Вот что я имею, никаких проблем только симулятор постоянно вылетает? Заранее спасибо.
#import <UIKit/UIKit.h>
@interface SImple_TableViewController : UIViewController
<UITableViewDelegate, UITableViewDataSource>
{
NSArray * listData;
NSArray* listPics;
}
@property (nonatomic,retain) NSArray *listData;
@property (nonatomic,retain) NSArray* listPics;
@end
#import "SImple_TableViewController.h"
@implementation SImple_TableViewController
@synthesize listData, listPics;
- (void)dealloc
{
[listData release];
[listPics release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
NSArray *array = [[NSArray alloc] initWithObjects:@"Bradley", @"Glen",@"Alan",@"Sean",@"Mark",@"Luke",@"Jack", nil];
NSArray *pics = [[NSArray alloc] initWithObjects:@"ME.jpg",@"Sean.jpg",@"Glenn.jpg",@"Mark.jpg",@"Luke.jpg",@"Jack.jpg",@"Alan.jpg", nil];
self.listData = array;
// self.listPics = pics;
[array release];
[pics release];
[super viewDidLoad];
}
- (void)viewDidUnload
{
self.listData = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark -
#pragma mark Table View Data Source Methods
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.listData count];
return [self.listPics count];
}
-(UITableViewCell*)tableView:(UITableView*) tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{ static NSString *SimpleTableIdentifier = @"SImpleTableIdentifier";
UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if(cell == nil)
{
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier]autorelease];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [listData objectAtIndex:row];
return cell;
UIImage*image = [UIImage imageNamed: listPics];
cell.imageView.image = [listPics objectAtIndex:row];
return cell;
}
@end