Работа с TableView под iOS 7?

Проблема следующего характера.

Требуется вывести в Alert таблицу. Запускаю через эмулятор iPhone 6.1, метод (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath подхватывается и все работает. На iOS 7 среда как-будто бы этот метод и не видит. В чем может быть проблема?


Код:
#import "AlertTableView.h"

@implementation AlertTableView

@synthesize  caller, context, data;

-(id)initWithCaller:(id)_caller data:(NSMutableArray *)_data title:(NSString *)_title andContext:(id)_context{
       
    NSString *messageString = @"\n\n\n\n\n\n";
    tableHeight = 125;
    
    
    
    self = [super initWithTitle:_title message:messageString delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
    if (self)
    {
        self.caller = _caller;
        self.context = _context;
        DLog(@"%@",_data);
        self.data = _data;
        [self prepare];
    }
    
    return self;
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    [self.caller didSelectRowAtIndex:-1 withContext:self.context];
}

-(void)show
{
    self.hidden = YES;
    [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(myTimer:) userInfo:nil repeats:NO];
    [super show];
}

-(void)myTimer:(NSTimer*)_timer
{
    self.hidden = NO;
    [myTableView flashScrollIndicators];
}

-(void)prepare
{
    myTableView = [[UITableView alloc] initWithFrame:CGRectMake(11, 50, 261, tableHeight) style: UITableViewStylePlain];
    if([data count] < 5)
    {
        myTableView.scrollEnabled = NO;
    }
    
    myTableView.delegate = self;
    myTableView.dataSource = self;
    [self addSubview: myTableView];
    
    
    UIImageView *imgView = [[[UIImageView alloc] initWithFrame:CGRectMake(11, 50, 261, 4)] autorelease];
    imgView.image = [UIImage imageNamed:@"top.png"];
    [self addSubview:imgView];
    
    imgView = [[[UIImageView alloc] initWithFrame:CGRectMake(11, tableHeight + 46, 261, 4)] autorelease];
    imgView.image = [UIImage imageNamed:@"bottom.png"];
    [self addSubview:imgView];
    
    CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 10);

    [self setTransform:myTransform];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = (UITableViewCell*) [tableView dequeueReusableCellWithIdentifier: @"ABC"];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ABC"] autorelease];
        
        cell.selectionStyle = UITableViewCellSelectionStyleBlue;
        cell.textLabel.font = [UIFont boldSystemFontOfSize: 14];
        
    }
    cell.textLabel.text = [[data objectAtIndex:indexPath.row] description];
    DLog(@"%@",[[data objectAtIndex:indexPath.row] description]);
    return cell;
}


///////FOR DELETING

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

- (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    // If row is deleted, remove it from the list.
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        // delete your data item here
        // Animate the deletion from the table.
        [self.data removeObjectAtIndex: indexPath.row];
        [myTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationFade];
        
        
        //delegate to del file with filename
        [self.caller didDeleteRowAtIndex: indexPath.row];
    }
}

/////////////

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self dismissWithClickedButtonIndex:0 animated:YES];
    [self.caller didSelectRowAtIndex:indexPath.row withContext:self.context];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [data count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

-(void)dealloc
{
    self.data = nil;
    self.caller = nil;
    self.context = nil;
    [myTableView release];
    [super dealloc];
}

@end
  • Вопрос задан
  • 3589 просмотров
Решения вопроса 1
@IgorFedorchuk
Я так понимаю, что AlertTableView наследник от UIAlertView? В таком случае вот что написано в документации Apple.
The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы