2013-11-21 3 views
0

Я использую проект GitHub под названием SWTableViewCell. Тем не менее, я постоянно получаю эту ошибку: No visible @interface for 'NSMutableArray' declares the selector 'addUtilityButtonWithColor:icon:'.Нет видимого @interface для 'NSMutableArray' объявляет селектор 'addUtilityButtonWithColor: icon:'

Пострадавшая код здесь:

- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    static NSString *cellId = @"Cell"; 

    SWTableViewCell *cell = (SWTableViewCell *)[table dequeueReusableCellWithIdentifier:cellId]; 

    if (cell == nil) { 
     NSMutableArray *leftUtilityButtons = [NSMutableArray new]; 
     NSMutableArray *rightUtilityButtons = [NSMutableArray new]; 

     [leftUtilityButtons addUtilityButtonWithColor: 
     [UIColor colorWithRed:0.00 green:0.4 blue:225 alpha:1.0] 
               icon:[UIImage imageNamed:@"check.png"]]; 
     [leftUtilityButtons addUtilityButtonWithColor: 
     [UIColor colorWithRed:0.0 green:0.5 blue:225 alpha:1.0] 
               icon:[UIImage imageNamed:@"clock.png"]]; 
     [leftUtilityButtons addUtilityButtonWithColor: 
     [UIColor colorWithRed:0.0 green:0.6 blue:225 alpha:1.0] 
               icon:[UIImage imageNamed:@"cross.png"]]; 
     [leftUtilityButtons addUtilityButtonWithColor: 
     [UIColor colorWithRed:0.0 green:0.7 blue:225 alpha:1.0] 
               icon:[UIImage imageNamed:@"list.png"]]; 


     [rightUtilityButtons addUtilityButtonWithColor: 
     [UIColor colorWithRed:1.0f green:0.231f blue:0.188 alpha:1.0f] 
               title:@"Delete"]; 

     cell = [[SWTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
             reuseIdentifier:cellId 
            containingTableView:table // For row height and selection 
            leftUtilityButtons:leftUtilityButtons 
            rightUtilityButtons:rightUtilityButtons]; 
     cell.delegate = self; 

     cell.textLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:18]; 
     cell.detailTextLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:13]; 
    } 
    // Configure cell 

    // Sets the text for the cell 

    cell.textLabel.text = [NSString stringWithFormat:@"Testing"]; 
    cell.detailTextLabel.text = [NSString stringWithFormat:@"This is a test."]; 

    return cell; 

} 

Почему это не работает? Заранее спасибо.

+1

Я думаю, вы должны иметь категорию по NSMutableArray, которые содержат метод: 'addUtilityButtonWithColor: значок:'. – Greg

+0

В соответствии с примером в [GitHub] (https://github.com/CEWendel/SWTableViewCell) имя метода - 'sw_addUtilityButtonWithColor'. – Rob

+0

Вы потеряли категорию NSMutableArray + SWUtilityButtons http://ios-blog.co.uk/tutorials/swtableviewcell-expose-utility-buttons-with-an-easy-to-use-uitableviewcell-subclass/ –

ответ

2

Вам необходимо посмотреть документы для SWTableViewCell. Метод называется:

sw_addUtilityButtonWithColor:icon: 

Так что вы хотите:

[leftUtilityButtons sw_addUtilityButtonWithColor: 
    [UIColor colorWithRed:0.00 green:0.4 blue:225 alpha:1.0] 
              icon:[UIImage imageNamed:@"check.png"]]; 
+2

Кстати, это своего рода грубый способ делать вещи, если вы спросите меня. –

+0

@AndrewMadsen Согласен. Добавление метода категории в 'NSMutableArray' просто для того, чтобы сделать его немного легче, чем создать кнопку, является хромой. – rmaddy

+0

Исправлено. Он работает сейчас. И я согласен с @AndrewMadsen: это не самый лучший способ сделать что-то. – chrisjr

Смежные вопросы