Ecco il codice che sto utilizzando:Non è possibile ottenere a livello di codice fatto UIButton di lavorare - iPhone
-(void)viewDidLoad
{
NSString *checkerPath = [[NSBundle mainBundle] pathForResource:@"black-yellow-checker" ofType:@"png"];
UIImage *checkerImage = [[UIImage alloc] initWithContentsOfFile:checkerPath];
checkerView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 230.0f, 320.0f, 280.0f)];
[checkerView setImage:checkerImage];
UIButton *backButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
backButton.frame = CGRectMake(45.0f, 175.0f, 230.0f, 50.0f);
[backButton setBackgroundImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"yellowButton" ofType:@"png"]] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(goBackHome:) forControlEvents:UIControlEventTouchDown];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
backButton.titleLabel.font = [UIFont fontWithName:@"Marker Felt" size:30];
backButton.titleLabel.textColor = [UIColor blackColor];
[checkerView addSubview:backButton];
}
- (void)goBackHome:(id)sender
{
NSLog(@"go back pressed");
}
Non capisco perché questo non funziona. Il pulsante appare, ma quando premo non succede nulla. Non cambia nemmeno nell'immagine "rientrata" quando la tocco. Niente. Non è possibile utilizzare IB, deve essere programmatico. qualche idea?
AHA. pensavo che sarebbe stato di default. dal momento che sei così ben informato dovresti provarci http://stackoverflow.com/questions/3808087/where-to-find-what-mkdomainerror-error-error-4-means – Marty