こんにちは、私は StackOverFlow と iOS 6 の初心者です。
経験豊富な開発者にとってはとても簡単です..
.h ファイルで..
@interface NotKnownDetailView : UITableViewController
@property (weak, nonatomic) IBOutlet UILabel *wordLabel;
@end
.m ファイルで..
@interface NotKnownDetailView ()
- (void)configureView;
@end
@implementation NotKnownDetailView
@synthesize wordLabel = _wordLabel ;
- (void)configureView{
wordData *theSighting = self.word_data;
if (theSighting) {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!"
message:theSighting.verbal
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
self.wordLabel.text = theSighting.word;
UIAlertView *message2 = [[UIAlertView alloc] initWithTitle:@"Hello World!"
message: self.verbalLabel.text
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message2 show];
}
}
問題は次のとおりです..
self.wordLabel.text = theSighting.word;
theSighting.word にはデータがありますが、self.wordLabel.text にはデータが含まれていません...
ストーリーボードで IBOutlet を接続しました。
上記の何が間違っていますか?
編集しました。 ソースの一部を追加します。これで不快にならないことを願っています。
// NotKnownDetailView.h
#import <UIKit/UIKit.h>
@class wordData ;
@interface NotKnownDetailView : UITableViewController
@property (strong, nonatomic) wordData *word_data;
@property (weak, nonatomic) IBOutlet UILabel *wordLabel;
@property (weak, nonatomic) IBOutlet UILabel *meanLabel;
@property (weak, nonatomic) IBOutlet UILabel *verbalLabel;
@end
// NotKnownDetailView.m
#import "NotKnownDetailView.h"
#import "wordData.h"
@interface NotKnownDetailView ()
//@property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView;
@end
@implementation NotKnownDetailView
@synthesize word_data = _word_data, wordLabel = _wordLabel, meanLabel = _meanLabel, verbalLabel = _verbalLabel;
// it is getter setter..
- (void)setWord_data:(wordData *) newWord
{
if (_word_data != newWord) {
_word_data = newWord;
[self configureView];
}
}
- (void)configureView
{
wordData *theSighting = self.word_data;
if (theSighting) {
NSLog(@" Word : %@" ,theSighting.word);
self.wordLabel.text = theSighting.word;
self.meanLabel.text = theSighting.mean;
self.verbalLabel.text = theSighting.verbal;
}
}
- (void)viewDidUnload
{
self.word_data = nil;
[super viewDidUnload];
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end
// wordData.h
#import <Foundation/Foundation.h>
@interface wordData : NSObject
@property (nonatomic, copy) NSString *word;
@property (nonatomic, copy) NSString *mean;
@property (nonatomic, copy) NSString *verbal;
-(id)initWithName:(NSString *)word meaning:(NSString *)mean verbaling:(NSString *)verbal;
@end
// wordData.m
#import "wordData.h"
@implementation wordData
@synthesize word = _word, mean = _mean , verbal = _verbal ;
-(id)initWithName:(NSString *)word meaning:(NSString *)mean verbaling:(NSString *)verbal{
{
self = [super init];
if (self) {
_word= word;
_mean = mean;
_verbal = verbal ;
return self;
}
return nil;
}
}
@end
有機EL。