我想让UIButton显示一个图像,并且正在获取标题错误。在'BSViewController *'类型的对象上找不到属性“窗口”
另外我想知道为什么()
需要BSViewController()
,因为它是由XCode创建的?
//
// BSViewController.m
#import "BSViewController.h"
@interface BSViewController() // Why the "()"?
@end
@implementation BSViewController
- (IBAction) chooseImage:(id) sender{
UIImageView* testCard = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ipad 7D.JPG"]];
//Property 'window' not found on object of type 'BSViewController *'
self.window.rootViewController = testCard;
[self.window.rootViewController addSubview: testCard];
testCard.center = self.window.rootViewController.center;
NSLog(@"chooseImage");
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// BSViewController.h
#import <UIKit/UIKit.h>
@class BSViewController;
@interface BSViewController : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>{
IBOutlet UIButton* chooseImage;
}
- (IBAction) chooseImage:(id) sender;
@end
当我进入这个'@财产(非原子,保留)的UIWindow *窗口;'我得到的错误'不兼容的指针类型从的UIImageView分配到的UIViewController * __strong '。 – zerowords