首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

ios 内存储器管理

2013-02-19 
ios 内存管理//创建自己的scrollview.??? myScrollView [[UIScrollView alloc]initWithFrame:CGRectMake

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;
}

?

?

热点排行