【这边走Cell IBoutlet】
1.从ios/User interface/Empty添加新文件。2. 从对象中添加表格视图单元格并在其中添加标签。2.给标签标签1加上设置对齐权(如下图所示)
[1]: http://i.stack.imgur.com/8AzJH.png
现在在您的 tableview 委托方法中添加以下行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *cellid =@"Cellid";
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellid];
if(cell==nil){
cell =[[[NSBundle mainBundle] loadNibNamed:@"cell" owner:self options:nil] objectAtIndex:0];
//[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
}
UILabel *celllabel = (UILabel*)[cell viewWithTag:1];
celllabel.text =@"Test label alignment";
return cell;
}
这对我来说非常有用。