making a minesweeper program for iphone having issues with navbar and adding images to a scroll view
originally i had a navigation bar with some buttons on it. in interface builder i hooked a button up with the "newGame" action on my main (autocreated) viewcontroller. "newGame" just outputs the board to the console,as a test to see if it's working. well it wasn't. so i decided to get rid of the navbar and just place the button in the main view and hooked it back up like before and it started working. is that because i didn't set up my main view controller as a navbar delegate or responder?
the other issue is getting the mine squares to show up in the scrollview.
@interface mineViewController : UIViewController {
//views
IBOutlet UIButton *newGame;
IBOutlet UIScrollView *boardView;
IBOutlet UILabel *minesLeft;
IBOutlet UILabel *timer;
UIButton *options;
UIButton *flag;
//modles
board *currGame;
}
-(void) awakeFro开发者_运维问答mNib
{
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];
}
Use UIBarButton instead of UIButton.
IBOutlet UIBarButton *newGame;
精彩评论