【问题标题】:IOS 6 Subclass not updating UITextField in UITableViewCellIOS 6 子类不更新 UITableViewCell 中的 UITextField
【发布时间】:2012-11-18 11:15:33
【问题描述】:

我有一个 UITableView,它处于原型模式。我已将 4 个标签和 2 个文本字段放入一个单元格中,其中一个单元格是基本的文本输入,并且工作正常。

我对 TableViewCell 进行了子类化。

头文件

#import <UIKit/UIKit.h>

@interface witLeagueSeriesGameDetailCell : UITableViewCell

@property (strong, nonatomic) IBOutlet UILabel *witGameNumber;
@property (strong, nonatomic) IBOutlet UITextField *witGameScore;
@property (strong, nonatomic) IBOutlet UITextField *witGameResult;

- (void) SetGameResult:(NSString *)resultName;

@end

实施文件

#import "witLeagueSeriesGameDetailCell.h"
#import "witAppDelegate.h"

@implementation witLeagueSeriesGameDetailCell

@synthesize witGameNumber=_witGameNumber;
@synthesize witGameScore = _witGameScore;
@synthesize witGameResult = _witGameResult;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void) SetGameResult:(NSString *)resultName{

    NSLog([NSString stringWithFormat:@"%@",resultName]);
    //self.witGameResult.text = resultName;
    [_witGameResult setText:resultName];
}



@end

tableview 也被子类化了。它包含一个在输入适当的文本字段时弹出的选择器。选择行时,它将值传递回setGameresult函数,我可以使用nslog

看到此版本

但是,单元格的文本不会在屏幕上更新。

从代码中可以看出,我尝试了点概念方法和消息方法来设置文本。

TVC 选择器代码是

- (void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    witLeagueSeriesGameDetailCell *myLabel = [[witLeagueSeriesGameDetailCell alloc] init];
    [myLabel SetGameResult:[NSString stringWithFormat:@"%@",[self.statusList objectAtIndex:row]]];

}

关于为什么它可能无法在屏幕上显示的任何想法

【问题讨论】:

    标签: uitableview ios6


    【解决方案1】:

    这些是 IBOutlets,所以它们应该连接到故事板上的那些。

    【讨论】:

      猜你喜欢
      • 2013-02-14
      • 1970-01-01
      • 2012-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多