मैंने एक टेबल जोड़ा है और इसमें एक तालिका दृश्य कक्ष खींच लिया है। उपयोगिता पैनल में , मैंने शैली को उपशीर्षक में बदल दिया। मैं भी कोड में इसे बदलने की कोशिश की है:आईओएस - UITableViewCell टेक्स्ट संरेखण
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.textAlignment = UITextAlignmentCenter;
cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
cell.textLabel.text = [myArray objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [myArray2 objectAtIndex:indexPath.row];
return cell;
केंद्र संरेखण काम नहीं करता है!
मैंने वर्कअराउंड करने के लिए सेल पर एक लेबल ऑब्जेक्ट जोड़ने का प्रयास किया है। लेकिन मुझे नहीं पता कि इसे कैसे पहुंचाया जाए। भले ही मैं इसे करने के लिए एक आउटलेट सौंपा, यह काम नहीं होगा:
cell.labelForCell....
मुझे क्या करना चाहिए? सेल या कुछ लेबल जोड़ने के बिना, मैं इसे सामान्य तरीके से कैसे काम करता हूं, इस पर कोई सुझाव?
बस एक fyi, NSTextAlignmentCenter का उपयोग करें। UITextAlignmentCenter बहिष्कृत है। – Viper