2013-12-23 3 views
2

Я добавляю tableView к viewController, который имеет собственный размер, т.е. я определяю его фрейм. Я не задал свой делегат, так как я не хочу, чтобы tableView выполнял какие-либо действия. Даже если я его установил, ошибки будут одинаковыми. Теперь это tableView заполняется array изображений. Когда я запускаю приложение, выдает исключение [__ NSCFConstantString size].Добавление TableView в UIViewController показывает ошибку [__ NSCFConstantString]

Вот что я делаю

enter image description here

Это DataSource Tableview определено в viewDidLoad.

menuArray = [[NSArray alloc]initWithObjects:@"icone_what1c.jpg",@"icone_what3c.jpg", @"icone_what2c.jpg",@"icone_what4c.jpg" ,nil]; 

И tableView методы источника данных.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 
     return [menuArray count]; 
    } 


    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     static NSString *cellIdentifier = @"Cell"; 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
     if (cell == nil) { 
     cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
    } 

     cell.imageView.image = [menuArray objectAtIndex:indexPath.row]; 
     return cell; 
    } 

И это краткое изложение исключения.

[__NSCFConstantString size]: unrecognized selector sent to instance 0x1e25c 
    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString size]: unrecognized selector sent to instance 0x1e25c' 
    *** First throw call stack: 
    (
0 CoreFoundation      0x01ce85e4 __exceptionPreprocess + 180 
1 libobjc.A.dylib      0x018d88b6 objc_exception_throw + 44 
2 CoreFoundation      0x01d85903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275 
3 CoreFoundation      0x01cd890b ___forwarding___ + 1019 
4 CoreFoundation      0x01cd84ee _CF_forwarding_prep_0 + 14 
5 UIKit        0x0059343f -[UIImageView setImage:] + 389 
6 AirMapp        0x0000f187 -[MainViewController tableView:cellForRowAtIndexPath:] + 375 
7 UIKit        0x0052cd2f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412 
8 UIKit        0x0052ce03 -[UITableView _createPreparedCellForGlobalRow:] + 69 
9 UIKit        0x00511124 -[UITableView _updateVisibleCellsNow:] + 2378 
10 UIKit        0x005245a5 -[UITableView layoutSubviews] + 213 
11 UIKit        0x004a8dd 

ответ

4

Изменение этой линии

cell.imageView.image = [menuArray objectAtIndex:indexPath.row]; 

в

cell.imageView.image = [UIImage imageNamed:[menuArray objectAtIndex:indexPath.row]]; 
+0

Thanx много .... это сработало: -] – icodes

+0

мое удовольствие .. :) –

Смежные вопросы