ios 内存管理
//创建自己的scrollview.
??? myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 180)];
??? self.myScrollView.backgroundColor = [UIColor whiteColor];
??? self.myScrollView.contentSize=CGSizeMake(320, 200);
??? UIImageView *shopImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 180)];
??? shopImageView.image = [UIImage imageNamed:@"shopImageDemo.png"];
??? [self.myScrollView addSubview:shopImageView];
??? [self.view addSubview:self.myScrollView];
??? self.myScrollView.scrollEnabled = NO;
??? [myScrollView release];
??? [shopImageView release];
???
??? //创建自己的tableview.
??? myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 180, 320, 300) style:UITableViewStyleGrouped];
??? self.dataArray=[NSMutableArray arrayWithObjects:@"店铺简介",@"经典发型",@"地图位置",@"热线电话:010-66228989", nil];
??? self.myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
??? self.myTableView.separatorColor = [UIColor grayColor];
??? self.myTableView.dataSource=self;
??? self.myTableView.delegate=self;
??? self.myTableView.backgroundView = nil;
??? self.myTableView.scrollEnabled = NO;
??? self.myTableView.backgroundColor = [UIColor grayColor];
??? [self.view addSubview:self.myTableView];
??? [myTableView release];
?
?//section里面的内容。
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
??? UILabel *shopNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 3, 100, 30)];
??? shopNameLabel.backgroundColor = [UIColor clearColor];
??? shopNameLabel.text = @"金融街店";
??? shopNameLabel.textColor = [UIColor whiteColor];
?? ?
??? UILabel *shopAddressLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 35, 300, 20)];
??? shopAddressLabel.backgroundColor = [UIColor clearColor];
??? shopAddressLabel.text = @"北京市西城区金融大街甲26号顺成饭店首层";
??? [shopAddressLabel setFont:[UIFont fontWithName:@"Arial" size:13]];
??? shopAddressLabel.textColor = [UIColor whiteColor];
?? ?
??? UIView *sectionView=[[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 70)]autorelease];
??? [sectionView setBackgroundColor:[UIColor grayColor]];
??? [sectionView addSubview:shopNameLabel];
??? [sectionView addSubview:shopAddressLabel];
??? [shopNameLabel release];
??? [shopAddressLabel release];
//??? [sectionView release];//这里不能直接release了,只能autorelease就行了。
??? return sectionView;
}
?
?