1.如何将自定义的header和cell放到tableView上面
以自定义cell为例,在工程中创建一个类CustomizedCell(带xib的)基于UIViewController,在这个类中把cell要用的控件都创建并且初始化出来,入cell上面放label,放image,都要在这个类中初始化
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
在这个方法中创建CustomizedCell类的指针,
CustomizedCell *cell = (CustomizedCell*)[tableView dequeueReusableCellWithIdentifier:ShoppingListCellIdentifier];
if (cell == nil) {
cell = [[self.customizedCellNib instantiateWithOwner:self options:nil] objectAtIndex:0]; //注意这种初始化方法
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
2.UINib这个类的用法?
UINib是iOS4.0之后引入的新类,主要作用是加速频繁使用的nib文件。第一次用这个nib文件的时候从硬盘加载,然后在内存中缓存nib文件的对象,在用nib文件时候可以直接从内存中拷贝,不需要在从硬盘中加载。
3.
NSIndexPath类的使用
这个类的对象有两个属性,一个是row,一个是section,注意对这个类的对象初始化的方法:
NSIndexPath *path = [NSIndexPath indexPathForRow:1 inSection:2];
这个path就被初始化为第三组的第二行。
4.
UIAlertViewDelegate方法使用回顾
方法名:alertView: clickedButtonAtIndex:
一开始要判断是按的哪一个button
if([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@”确定”])
5.NSMutableArray的另外一个方法:
removeObjectsInArray:把在array数组中的在mutableArray中的对象从mutableArray中删除掉。注意区别开
removeAllObjects
removeObjectAtIndexPath