I searched in other posts, but I could not find a solution.
I have a UIButton that cannot be clicked. When I click, it does not get dark. The problem is not the selection method.
Can someone help me ?! Here is the code:
- (void)drawRect:(CGRect)rect
{
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 436)];
UIView *detailsView = [[UIView alloc] init];
UIButton *btnOpenPDF = [UIButton buttonWithType:UIButtonTypeCustom];
[btnOpenPDF setBackgroundImage:[UIImage imageNamed:@"btnVisualizarPdf"] forState:UIControlStateNormal];
[btnOpenPDF setFrame:CGRectMake(35, totalHeight, 249, 30)];
btnOpenPDF.userInteractionEnabled = YES;
[btnOpenPDF addTarget:self action:@selector(openPdf:) forControlEvents:UIControlEventTouchDown];
[detailsView addSubview:btnOpenPDF];
[scroll addSubview:detailsView];
[self addSubview:scroll];
}
The code above is inside the UIView, which is called through the UIViewController using the -loadView () method.
Below is the openPdf method:
- (IBAction)openPdf:(id)sender{
UIWebView *aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320,450)];
aWebView.scalesPageToFit = YES;
[aWebView setDelegate:self];
NSURL *urlString = [NSURL URLWithString:[NSString stringWithFormat:@"http://portalarp.com.br/portal/%@",[[[[[[[delegateFunctions products] objectAtIndex:[delegateFunctions selectedProductIndex]] objectForKey:@"ata"] objectForKey:@"nm_arquivo"] objectForKey:@"text"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] stringByReplacingOccurrencesOfString:@"\t" withString:@""]]];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:urlString];
[aWebView loadRequest:requestObj];
[self addSubview:aWebView];
[aWebView release];
}
source
share