我寫了一些Objective-C代碼,我想不通爲什麼這不起作用:錯誤:不兼容的類型分配
buttonRect = CGRectMake(0,0,100.0,100.0);//error:incompatible types in assignment
CGRect newFrame = CGRectInset(buttonRect, -0.2, -0.2);//error:incompatible type for argument 1 of CGRectInset
button.frame = newFrame;
buttonRect是的CGRect定義爲我的類的實例變量,而按鈕是一個也被定義爲實例變量的UIButton。爲什麼這不起作用? 我的頭文件:
//
// MyViewController.h
// HelloWorld
//
// Created by RCIX on 7/10/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController {
UITextField *textField;
UILabel *label;
NSString *string;
UIButton *button;
CGRect *buttonRect;
}
@property (nonatomic, assign) CGRect *buttonRect;
@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, retain) IBOutlet UIButton *button;
@property (nonatomic, retain) NSString *string;
- (IBAction)helloButtonDown:(id)sender;
- (IBAction)helloButtonUp:(id)sender;
@end
複製並粘貼buttonRect的聲明。 – Chuck 2009-07-14 00:52:49