views:

26

answers:

1

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) 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];
}
A: 

Use UIBarButton instead of UIButton.

IBOutlet UIBarButton *newGame;
krishnakanthc
notice that i didn't ask how to do it, as i got it working a different way i asked why.and i'm pretty sure i used bar button when using the nav bar.
mavriksc
Unless I see the nib file I can only guess on why it did not work. Alternative is to do what you did and try hooking up a selector from code. So atleast we can rule out IB mistakes.try this .. [myButton addTarget:self action:@selector(myAction) forControlEvents:UIControlEventTouchDown]
krishnakanthc