我的目標是在標籤中顯示名爲文件的自定義類的對象的文本。這裏是Files.h:無法在標籤中顯示對象的文本
#import <Foundation/Foundation.h>
@interface Files : NSObject
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *text;
@end
這是Files.m:
#import "Files.h"
@implementation Files
@dynamic title;
@dynamic text;
@end
這裏是我的應用程序的.h文件。標籤被稱爲TRACKNAME:
#import <UIKit/UIKit.h>
#import "Files.h"
@interface FirstViewController : UIViewController
{
Files *plainpalais;
}
@property (weak, nonatomic) IBOutlet UILabel *trackName;
-(Files*) chooseFile;
@end
這是應用程序的.m文件:
#import "FirstViewController.h"
@interface FirstViewController()
@end
@implementation FirstViewController
@synthesize trackName;
-(Files*)chooseFile
{
return plainpalais;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[email protected]"hello";
[email protected]"plainpalais";
trackName.text=plainpalais.title;
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setTrackName:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end
的問題是,標籤TRACKNAME不顯示普蘭帕拉斯...
謝謝求助 ! PS:我是初學者,所以這可能是一個基本的錯誤。
您是否使用Interface Builder將「trackName」鏈接到UI對象? – trojanfoe
是的!我認爲問題在於我如何聲明Files類和東西。事實上,如果我要求做trackName.text = @「hello」;有用 !! – Pao