我想讓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