Sunday, December 29, 2013

Questions about tableviewcontroller

 

- (Void) viewDidLoad
{
[Super viewDidLoad];
dataTable * _mytable = [[dataTable alloc] init];
self.dataTableView = _mytable;
/ / [_mytable Release];
NSMutableArray * _myArray = [[NSMutableArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys: @ "Hangzhou Water Industry Group Limited Southern Star Waterworks", @ "qyName",
@ "20 April 2011", @ "time",
nil],
nil];
self.tableDataArray = _myArray;
[_myArray Release];
/ / Self.tableDataArray = dataTableView.tableDataArray;
self.myTableViewController = self.dataTableView;
/ / Do any additional setup after loading the view from its nib.
[Self.view addSubview: _mytable.view];
}



The question is:
Now [self.view addSubview: _mytable.view]; energy bar table add up, but self.dataTableView = _mytable; After the assignment, and replaced with [self.view addSubview: elf.dataTableView.view]; unable realistic form, what is this The reason? I am a novice, did not get to know. . . Thank you.
Reply:
You feel the full implementation of the code written in viewDidLoad not appropriate, viewDidLoad should be just a load of data arrays to achieve

If you are dynamically generated form, the proposal controller written in a separate class

dataTable * _mytable = [[dataTable alloc] init];
self.dataTableView = _mytable;
---------------------
You do not know what the purpose of these two lines of code, why write here, the other controller class functions do not know how you write






Reply:
 - (void) viewDidLoad 
{
[Super viewDidLoad];
dataTable * _mytable = [[dataTable alloc] init];
NSMutableArray * _myArray = [[NSMutableArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys: @ "Hangzhou Water Industry Group Limited Southern Star Waterworks", @ "qyName",
@ "20 April 2011", @ "time",
nil],
nil];
self.tableDataArray = _myArray;
[_myArray Release];
_mytable.tableDataArray = self.tableDataArray;


self.myTableViewController = _mytable;
/ / Do any additional setup after loading the view from its nib.
[Self.view addSubview: _mytable.view];

}


Changed a bit, myTableViewController IB is a link, in other ways where you want to modify it.

No comments:

Post a Comment