2014-07-16 5 views
1

사용자 정의 UITableViewCellUITableView에 삽입 된 UITableView이 있습니다.사용자 지정 UITableViewCell 내의 UiTableView

맞춤 UITableViewCell의 클래스가있다 :

@interface XYZcustomtakeawayTableViewCell: UITableViewCell <UITableViewDataSource,UITableViewDelegate> 
{ 
     NSString * order; 
} 

@property (strong, nonatomic) IBOutlet UITableView * tableviewinside; 
@property (nonatomic, retain) NSString * order; 

@end 




#import "XYZcustomtakeawayTableViewCell.h" 

@implementation {XYZcustomtakeawayTableViewCell 
{ 
     NSMutableArray * dataArray; 
} 

@synthesize tableviewinside, order; 

- (id) initWithStyle: (UITableViewCellStyle) style reuseIdentifier: (NSString *) reuseIdentifier: (NSString *) Order 
{ 
     self = [super initWithStyle: style reuseIdentifier: reuseIdentifier]; 
     if (self) { 
         // Initialization code     
     } 
     return self; 
} 

- (void) awakeFromNib 
{ 
     // Initialization code 
     
     
    
     dataArray = [[order componentsSeparatedByString: @ ""] mutableCopy]; 

     self.tableviewinside.delegate = self; 
     self.tableviewinside.dataSource = self; 

} 

- (void) setSelected: (BOOL) selected animated: (BOOL) animated 
{ 
     [super setSelected: selected animated: animated]; 

    // Configure the view for the selected were 
} 

- (NSInteger) numberOfSectionsInTableView: (UITableView *) tableView 
{ 
     return 1; 
} 

- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section 
{ 
     dataArray = [[order componentsSeparatedByString: @ ""] mutableCopy]; 
     dataArray.count return; 
} 

- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath 
{ 
     UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: @ "cell"]; 
     if (cell == nil) 
     { 
         cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: @ "cell"]; 
     } 
     cell.textLabel.text = [dataArray objectAtIndex: indexPath.row]; 
     
     return cell; 
} 

@end 

클래스있는 UITableViewController

import <UIKit/UIKit.h> 


@interface XYZGestisciTakeAwayTableViewController: UITableViewController 

@end 

는 NSString * ordine_1 = @ "1 리타 2 나폴";

- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath 
{ 
     static NSString * simpleTableIdentifier = @ "cell"; 
  
     XYZcustomtakeawayTableViewCell * cell = (XYZcustomtakeawayTableViewCell *) [tableView dequeueReusableCellWithIdentifier: simpleTableIdentifier]; 
     
     if (cell == nil) 
     { 
              NSArray * nib = [[NSBundle mainBundle] loadNibNamed: @ "custom_prenotazioni" owner: self options: nil]; 
         cell = [nib objectAtIndex:0]; 
       
     } 
     
     cell.ordine = ordine_1; //FAILURE !!!!!!!!!!!! 
     
     
     
     
     return cell; 
} 

응용 프로그램 실행이 중지되는 이유는 무엇입니까? cell.ordine = ordine_1;을 삭제하면 작동합니다.

+0

사용자 정의 셀에서 'ordine'을 어디에 선언합니까? 나는'order'와'tableviewinside'를위한 프라퍼티만을 볼 수 있습니다. – Stonz2

+0

충돌이 일어나거나 멈 춥니 다? 또한 @ Stonz2는 – random

답변

0

나는 스스로에게 대답한다. 문제는 클래스의 문자열을 클래스 UITableViewCell로 전달하는 것입니다. UITableView에서 [[NSUserDefaults standardUserDefaults] ..와 문자열을 저장하고 사용자 정의 uitablevievcell 복구의 문자열을 제외하고 해결했습니다. 그래서 작동합니다. 그러나 나는 프로그램하는 가장 좋은 방법이라고 생각하지 않는다!

관련 문제