Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为iphone制作扫雷程序时,导航栏出现问题,并向滚动视图添加图像_Iphone_Uiscrollview_Uiimageview_Uinavigationbar - Fatal编程技术网

为iphone制作扫雷程序时,导航栏出现问题,并向滚动视图添加图像

为iphone制作扫雷程序时,导航栏出现问题,并向滚动视图添加图像,iphone,uiscrollview,uiimageview,uinavigationbar,Iphone,Uiscrollview,Uiimageview,Uinavigationbar,最初我有一个导航栏,上面有一些按钮。在interface builder中,我在主(自动创建的)viewcontroller上连接了一个带有“newGame”操作的按钮。“newGame”只是将棋盘输出到控制台,以测试它是否工作。事实并非如此。所以我决定去掉导航栏,只需将按钮放在主视图中,然后像以前一样将其连接起来,它就开始工作了。这是因为我没有将我的主视图控制器设置为navbar代理或响应程序吗 另一个问题是如何让地雷方块显示在滚动视图中 @interface mineViewControll

最初我有一个导航栏,上面有一些按钮。在interface builder中,我在主(自动创建的)viewcontroller上连接了一个带有“newGame”操作的按钮。“newGame”只是将棋盘输出到控制台,以测试它是否工作。事实并非如此。所以我决定去掉导航栏,只需将按钮放在主视图中,然后像以前一样将其连接起来,它就开始工作了。这是因为我没有将我的主视图控制器设置为navbar代理或响应程序吗

另一个问题是如何让地雷方块显示在滚动视图中

@interface mineViewController : UIViewController {
//views
IBOutlet UIButton *newGame;
IBOutlet UIScrollView *boardView;
IBOutlet UILabel *minesLeft;
IBOutlet UILabel *timer;
UIButton *options;
UIButton *flag;
//modles
board *currGame;

}

-(void) awakeFromNib
{
currGame=[[board alloc]init];
[currGame showBoard];
UIImage *piece = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"up" ofType:@"jpg"]];
[piece retain];
UIImageView *square = [[UIImageView alloc]initWithImage:piece];
[boardView addSubview:square];
}

使用UIBarButton而不是UIButton

IBOutlet UIBarButton *newGame;

请注意,我没有问怎么做,因为我以不同的方式工作,我问了为什么。我很确定我在使用导航栏时使用了bar按钮。除非我看到nib文件,否则我只能猜测它为什么不工作。另一种方法是按照您所做的操作,尝试从代码中连接选择器。所以我们至少可以排除IB的错误。试试这个。。[myButton addTarget:self action:@selector(myAction)for ControlEvents:uicontrol事件触地]