/ /
/ / TtttViewController.h
/ / Tttt
/ /
/ / Created by yjj on 11-5-24.
/ / Copyright 2011 年 __MyCompanyName__. All rights reserved.
/ /
# Import
@ Interface ttttViewController: UIViewController{
NSArray * nodelist;
}
@ Property (nonatomic, retain) NSArray * nodelist;
@ End
/ /
/ / TtttViewController.m
/ / Tttt
/ /
/ / Created by yjj on 11-5-24.
/ / Copyright 2011 年 __MyCompanyName__. All rights reserved.
/ /
# Import "ttttViewController.h"
@ Implementation ttttViewController
@ Synthesize nodelist;
- (Void) dealloc
{
[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
# Pragma markTableViewDataSource Methods
- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section {
return [self.nodelist count];
}
- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {
static NSString * NoteScanIdentifier = @ "NoteScanIdentifier";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: NoteScanIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: NoteScanIdentifier];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [nodelist objectAtIndex: row];
return cell;
}
/ *
/ / Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (Void) viewDidLoad
{
[Super viewDidLoad];
}
* /
- (Void) viewDidLoad
{
NSArray * array = [[NSArray alloc] initWithObjects: @ "2009-12-1", @ "2009-12-2", @ "2009-12-3", @ "2009-12-4", @ "2009 -12-5 ", @" 2009-12-6 ", nil];
self.nodelist = array;
[Array release];
[Super viewDidLoad];
}
- (Void) viewDidUnload
{
[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);
}
@ End
Reply:
Call call, someone you
Reply:
Call call, someone you
Reply:
See [tableView reloadData] under
Reply:
Where to write, or do?
Reply:
Wrong, wrong files you create, you create is
@ Interface ttttViewController: UIViewController,
And this should be done
UITableViewController@ Interface Conferencing: UITableViewController,
If you really want to add a UITableView in UIViewController, you need to add the code!
Reply:
So when you create the file is built directly TableView

Reply:
.....
This is in fact an example of code to write a tableview, and the data is loaded on.
No wrong.
Reply:
Or add a table up, and set the delegate to self and datesource
Reply:
If a TableView UIView added to the above, according to the 8th floor of the method have to do it, there is no problem
Reply:
Thank shulianyong, this is an example, I took it a guide >> << iphone application on the realization of a simple example of a table.
His premise is to use the View-based Application template's.
And. Xib the dragged a tableview. Then connect the file's owner two interfaces. Then write the program.
But written, there is a blank, I do not know xcode4 reasons, or what.
Reply:
Give you examples
UITableView * tableView = [[UITableView alloc] initWithFrame: CGRectMake (10, 40, frame.size.width-20, 200) style: UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
[Self.view addSubview: tableView];
[TableView release];
Reply:
Thank you very much, but I still want to use the example of a method to achieve.
Because I am in. Xlb has added a tableview. Was not xcode3 can be achieved in this case and the application or something else in xcode4 in practice?
Reply:
Because when you cite ttttViewController, is the direct use of init, this can not refer to your custom XIB,
[[TtttViewController alloc] initWithNibName: @ "ttttViewController" bundle: nil], so it is instantiated with a reference to your custom XIB
Reply:
This is a screenshot
Reply:
This is not the tube, in mainwindow view is automatically loaded in this, this is already built when you create on the.
Reply:
I have a little debugging your code, the code should not be a problem, I used your code to be a demo, showed no problem.
You might be a way to use xib file error on this issue there are so few points need to be addressed in the xib in
1. File's Owner to be connected with a View, press Ctrl even
DataSource and delegate two properties 2.table should also connect File's Owner
Nothing else should be on the
Reply:
I use xcode4. Could be the reason?
Reply:
Gray often thank you, by [Xiaohui _ Xi'an
Results posted.
No comments:
Post a Comment