Friday, December 27, 2013

xcode4 tableview test successfully compiled, showing a blank one, for help.

 
/ /
/ / 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:
reference to the third floor lvlin1980 reply:
[tableView reloadData] next look
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:
references, 5th Floor shulianyong reply:
wrong, you create the wrong file, 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!

.....
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:
reference to the 11th floor shulianyong 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;
......

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:
reference to the 13th floor shulianyong 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

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:
reference to the 16th floor lvlin1980 reply:
I have a little debugging your code, the code should not be a problem, I used your code to be a demo, display 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


Others should not have anything


I use xcode4. Could be the reason?
Reply:
Gray often thank you, by [Xiaohui _ Xi'an ] online guide, I will table_view the file's owner is connected, the error caused by the program itself is not the problem.
Results posted.

No comments:

Post a Comment