UIView的Text属性调用不出来

windergao 2016-03-06 08:59:50
// .h 文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *userInput;
@property (strong, nonatomic) IBOutlet UIView *userOutput;
- (IBAction)setOutput:(id)sender;
@end

//.m文件
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize userOutput;
@synthesize userInput;

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload {
self.userInput = nil;
self.userOutput = nil;
[self setUserInput:nil];
[self setUserOutput:nil];
[super viewDidUnload];
}

- (IBAction)setOutput:(id)sender
{
self.userOutput.text;//提示:Propety"text"not found on object of type"UIview"
self.userInput.textInputContextIdentifier;// 只有这个属性是返回NSString的
}
@end

如上述代码。UIView的对象 userinput.text会是错的,我是按照教程写的代码啊
...全文
109 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
windergao 2016-03-07
  • 打赏
  • 举报
回复
@property (weak, nonatomic) IBOutlet UILabel *userOutput; @property (weak, nonatomic) IBOutlet UITextField *userInput; 问题已发现,这两句写错了。

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧