我開始一個多視圖應用程序與兩個意見:新遊戲和玩家。我以爲我正在設置一切,但顯然不是。Xcode錯誤:不兼容的Objective-C類型。預期'結構UIView'
MainViewController.h
#import <UIKit/UIKit.h>
@class NewGame; @class Players;
@interface MainViewController : UIViewController {
IBOutlet NewGame *newGameController;
IBOutlet Players *playersController;
}
-(IBAction) loadNewGame:(id)sender;
-(IBAction) loadPlayers:(id)sender;
-(void) clearView;
@end
MainViewController.m
#import "MainViewController.h"
#import "NewGame.h"
#import "Players.h"
@implementation MainViewController
-(IBAction) loadNewGame:(id)sender {
[self clearView];
[self.view insertSubview:newGameController atIndex:0];
}
-(IBAction) loadPlayers:(id)sender {
[self clearView];
[self.view insertSubview:playersController atIndex:0];
}
-(void) clearView {
if (newGameController.view.superview) {
[newGameController.view removeFromSuperview];
} else if (playersController.view.superview) {
[playersController.view removeFromSuperview];
}
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[self loadNewGame:nil];
[super viewDidLoad];
}
一對夫婦的圖像...
http://i.stack.imgur.com/GwXMa.png HTTP://i.stack.imgur .com/XHktH.png
代碼塊每行用四個空格表示,而不是'>'。 http://stackoverflow.com/editing-help – BoltClock 2011-03-06 02:23:48