【发布时间】:2014-03-12 18:28:54
【问题描述】:
我的视图没有显示。
我创建了一个空应用程序并添加了一个按钮和一个 UIImageView。
我使用了故事板。 只有一个故事板。 一个箭头指向这个故事板。
我在 AppDelegate 中设置了 rootViewController。我在视图控制器中设置了下面的图像。
图像在 Images.xcassets 蓝色文件夹中列为“bl_5_00”。
红色按钮没有显示,这让我相信我搞砸了其他更具结构性的东西。
应用代理
#import "PEPI_AppDelegate.h"
#import "PEPI_LessonViewController.h"
@implementation PEPI_AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
PEPI_LessonViewController *controller = [[PEPI_LessonViewController alloc] init];
self.window.rootViewController = controller;
[self.window makeKeyAndVisible];
return YES;
}
视图控制器
#import "PEPI_LessonViewController.h"
@interface PEPI_LessonViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *mainImage;
@end
@implementation PEPI_LessonViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIImage *imageYouWantToPass = [UIImage imageNamed:@"bl_5_00"];
self.mainImage.image = imageYouWantToPass;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
【问题讨论】:
标签: ios objective-c uiimageview uiimage