我正在尝试让 UIButton 显示图像并收到标题错误。
另外我想知道为什么()
需要它,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