@interface TableListViewController : UITableViewController 佈局
@end spa
@implementation TableListViewController .net
//表格能夠以分段或者以單個列表的形式顯示其數據。對於簡單的表格,返回1,表示整個表格應該做爲一個列表顯示。在分段列表中,返回2及以上的值。 get
- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView it
{ io
return 1; table
} object
//第二個調用,此方法返回每一個分段的行數,處理簡單列表時,返回整個表格的行數。 List
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section scroll
{
NSLog(@"[UIFont familyNames].count,%d",[UIFont familyNames].count);
return [UIFont familyNames].count;
}
//第三個調用,返回某一個item
- (UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cellForRowAtIndexPath ,%@",indexPath);
UITableViewCellStyle style = UITableViewCellStyleDefault;
UITableViewCell *cell = [tView dequeueReusableCellWithIdentifier:@"BaseCell"];
if (!cell)
cell = [[[UITableViewCell alloc] initWithStyle:style reuseIdentifier:@"BaseCell"] autorelease];
cell.textLabel.text = [[UIFont familyNames] objectAtIndex:indexPath.row];
return cell;
}
//選中某一列的時候調用
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didSelectRowAtIndexPath ,%@",indexPath);
NSString *font = [[UIFont familyNames] objectAtIndex:indexPath.row];
[MAINLABEL setText:font];
[MAINLABEL setFont:[UIFont fontWithName:font size:18.0f]];
}
//第一個調用
- (void) loadView
{
NSLog(@"試圖控制器,loadview加載");
[super loadView];
self.navigationItem.titleView = [[[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 30.0f)] autorelease];
[MAINLABEL setBackgroundColor:[UIColor clearColor]];
[MAINLABEL setTextColor:[UIColor whiteColor]];
[MAINLABEL setTextAlignment:UITextAlignmentCenter];
}
//UIScrollViewDelegate 中的方法,滾動調用
- (void) scrollViewDidScroll: (UIScrollView *) sv
{
NSLog(@"scrollViewDidScroll調用");
float percent = sv.contentOffset.y / sv.contentSize.height;
percent = 0.25 + 3 * (MAX(MIN(1.0f, percent), 0.0f) / 4.0f);
self.tableView.backgroundColor = [UIColor colorWithRed:percent * 0.20392 green:percent * 0.19607 blue:percent * 0.61176 alpha: 1.0f];
}
TableListViewController *tlvc = [[TableListViewController alloc] init];
//設置tabview的總體佈局背景
tlvc.tableView.backgroundColor = COOKBOOK_PURPLE_COLOR;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:tlvc];
//設置UINavigationController的navigationBar背景顏色
nav.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;