我有一個看起來像this的動態TableView
。自定義動態TableViewCell文本定位
但是,我想更整齊地定位文本,如this。
這裏是我目前使用的代碼:我已經把一個標籤到我想要的動態文本是已位於TableViewCell
試驗
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier [email protected]"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
[cell.textLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:17.0f]];
cell.textLabel.text=[[self.responseArray objectAtIndex:indexPath.row]objectForKey:@"name"];
return cell;
}
,但我呼籲沒有成功它在我的代碼中。我怎樣才能做到這一點?
感謝您的回覆。我已經添加了一個標籤,並給它類myLabel。在'.h'文件中,我已經把'@property(nonatomic,strong)UILabel * myLabel;'和'.m'中的'myLabel'替換了'textLabel'的每個實例。我哪裏錯了? – Sebastian
類名應以大寫字母開頭。你得到一個編譯器警告說'myLabel是未定義的? – Wain
不,我得到的錯誤是在第6行,並說:'屬性'myLabel'找不到'UITableViewCell *'類型的對象。奇怪的是,第5行也出現了錯誤,但它消失了。 – Sebastian