我是新來的iPhone SDK,並試圖創建3個視圖,並在它們之間切換。數據將來自服務器,我將基本上顯示1個視圖並緩存另外兩個視圖。到目前爲止,我只是試圖創建一個視圖並在運行時顯示它。我的代碼列在下面。它只顯示一個空白屏幕,我想我錯過了一個關鍵概念。任何幫助?運行時的iPhone視圖?
#import <UIKit/UIKit.h>
#import "ImageViewController.h"
@interface Test5ViewController : UIViewController
{
IBOutlet UIView *rootView;
ImageViewController *curImage;
ImageViewController *nextImage;
ImageViewController *prevImage;
}
@property(nonatomic,retain) IBOutlet UIView *rootView;
@property(nonatomic,retain) ImageViewController *curImage;
@property(nonatomic,retain) ImageViewController *nextImage;
@property(nonatomic,retain) ImageViewController *prevImage;
@end
和
- (void)loadView
{
self.curImage = [[ImageViewController alloc]initWithNibName:@"ImageView" bundle:[NSBundle mainBundle]];
UIImage *pic = [UIImage imageNamed:@"baby-gorilla.jpg"];
[self.curImage assignImage:pic];
self.rootView = self.curImage.view;
}
和
#import <UIKit/UIKit.h>
@interface ImageViewController : UIViewController
{
IBOutlet UIImageView *image;
}
-(void)assignImage:(UIImage *)screenShotToSet;
@property(nonatomic,retain) IBOutlet UIImageView *image;
@end