Art*_*vin 3 cocoa-touch objective-c uiview iboutlet ios
我正试图UITextView在应用程序启动时显示一个字符串.我有一个UIView和一个UITextView在我的界面,一个插座,myText连接到UITextView.它似乎没有工作,我不能说为什么....
这是有问题的代码:
MainView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface MainView : UIView {
IBOutlet UITextView *myText;
}
@end
Run Code Online (Sandbox Code Playgroud)
MainView.m
@implementation MainView
-(id) initWithCoder:(NSCoder *)coder {
if ((self = [super initWithCoder:coder]) != nil)
{
NSLog(@"initWithCoder executed");
myText.text = @"Hello, World!";
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
该NSLog()打印信息,所以我认为这myText.text确实是设置为@"Hello World",但这并没有反映在我的UITextView.这里挂了哪里?如果它有帮助,这是我的实际应用程序的简化版本,当我将其myText.text = @"Hello, World!";放入响应按钮按下的方法时,更改将反映在文本视图中.
| 归档时间: |
|
| 查看次数: |
691 次 |
| 最近记录: |