Я следующий код в своем классе. Когда я запускаю свое приложение на симуляторе, он работает. Однако при запуске приложения на реальном устройстве (iPhone 1g, 3.1.3) он не работает. Есть идеи?Проблемы с фоном на UITableViewCell iPhone
(это для создания градиента фона)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MainScreenCellID = @"MainScreenCellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MainScreenCellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MainScreenCellID] autorelease];
}
cell.textLabel.text = [[[self.controllers objectAtIndex:[indexPath row]] navigationItem] title];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImageView *bgimage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_bg.png"]];
cell.backgroundView = bgimage;
[bgimage release];
for (UIView *view in cell.contentView.subviews) {
view.backgroundColor = [UIColor clearColor];
}
return cell;
}
EDIT (черные поля добавляется, потому что приложение еще не сделано.):
Я могу добавить что в UITableViewCell, с которым этот метод работает, я создал свои собственные подклассы, но где я использую UITableViewDefaultStyle, он не работает.
Любая статическая инициализация свойств, такая как accessoriesType и backgroundView, вы можете перейти к if (cell == nill) {...} – Victor