0

我正在尝试使用 UICollectionView,它是 viewCell。我很顺利。但是在 viewcell 表单上,我有一个按钮,我打算进入设置视图。我正在尝试“将其推入堆栈”。Xcode 抱怨“选择器没有可见的界面”。一些代码和错误消息如下。

// TryColViewCell.h

#import <UIKit/UIKit.h>
#import "TryColViewContViewController.h"


@interface TryColViewCell : UICollectionViewCell

@property (weak, nonatomic) IBOutlet UILabel *outletNameLBL;

@property (weak, nonatomic) IBOutlet UILabel *outletCellLabel;
@property (readwrite) NSInteger intTest;
@property (readwrite) TryColViewContViewController *theHost;




- (IBAction)actionPlus1:(id)sender;

- (IBAction)actionMinus1:(id)sender;


- (IBAction)actionNameEdit:(id)sender;

// TryColViewCell.m

#import "TryColViewCell.h"
#import "SettingsViewController.h"


@implementation TryColViewCell {
@public    int intCellNumber;  //TODO: get this to track the row/cell #
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (IBAction)actionPlus1:(id)sender {

}

- (IBAction)actionMinus1:(id)sender {

}


- (IBAction)actionNameEdit:(id)sender {
    NSLog(@"Name Edit");



    SettingsViewController *viewControllerB =
        [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];

    viewControllerB.propName = _outletNameLBL.text;
    [self pushViewController:viewControllerB animated:YES];
    [self.theHost  pushViewController:viewControllerB animated:YES];


}
@end

// PushVIewController 行上的错误消息

TryColViewCell.m:83:11: No visible @interface for 'TryColViewCell' 
declares the selector 'pushViewController:animated:'
4

1 回答 1

1

从包含集合视图的视图控制器中推送新的视图控制器,而不是单元格。只有一个子类具有重写UIViewController的方法。pushViewController:animated.

在您的表格视图控制器中,假设您使用的是故事板,请执行以下操作:

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

  static NSString* identifier = @"Cell";
  CellSubClass *cell = 
       (CellSubClass*) [tableView dequeueReusableCellWithIdentifier:identifier];

  [cell.upButton addTarget:self selector:@selector(actionPlus1:) 
       forControlEvent:UIControlEventTouchUpInside];
  [cell.downButton addTarget:self selector:@selector(actionMinus1:) 
       forControlEvent:UIControlEventTouchUpInside];

  ...
}
于 2013-10-19T15:56:46.330 回答