//  ViewController.h
    @interface ViewController : UIViewController{

        IBOutlet UIButton *btnname;
        IBOutlet UITextView *txtname;
        IBOutlet UILabel *lblname;

    }


    @property (retain, nonatomic) IBOutlet UITextField *txtname;

    @property (retain, nonatomic) IBOutlet UILabel *lblname;

    - (IBAction)Btntikla:(id)sender;

    @end

    //ViewController.m

    @implementation ViewController

    @synthesize txtname;//here it says -type of property txtname (uiTextView *) does not match of ivar txtname(uiTextView)- this mistakes

    @synthesize lblname;

- (void)dealloc {
    [lblname release];
    [txtname release];
    [super dealloc];
}
- (IBAction)Btntikla:(id)sender {

    NSString *name=[txtname text];
    lblname.text=name;
}
@end


//我的整个程序是this.it报错?属性txtname(uiTextView *)的类型与ivar txtname(uiTextView)的类型不匹配。我的错是什么?

最佳答案

那是因为你有

 @property (retain, nonatomic) IBOutlet UITextField *txtname;


IBOutlet UITextView *txtname;

UITextFieldUITextView是不同的控件

关于iphone - 属性txtname(uiTextView *)的类型与ivar txtname(uiTextView)的类型不匹配,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8924087/

10-10 09:40