다른 게시물을 검색했지만 해결책을 찾지 못했습니다.UIButton을 클릭 할 수 없습니다.
UIButton을 (를) 클릭 할 수 없습니다. 클릭하면 어두워지지 않습니다. 문제는 선택기 메서드가 아닙니다.
누군가 나를 도울 수 있습니까?! 코드는 다음과 같습니다.
- (void)drawRect:(CGRect)rect
{
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 436)];
UIView *detailsView = [[UIView alloc] init];
// I have other components here and after the UIButton
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];
}
위 코드는 -loadView() 메소드를 통해 UIViewController를 통해 호출되는 UIView 내부에 있습니다.
- (IBAction)openPdf:(id)sender{
// Creates an instance of a UIWebView
UIWebView *aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320,450)];
// Sets the scale of web content the first time it is displayed in a web view
aWebView.scalesPageToFit = YES;
[aWebView setDelegate:self];
//Create a URL object.
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:@""]]];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:urlString];
//load the URL into the web view.
[aWebView loadRequest:requestObj];
[self addSubview:aWebView];
[aWebView release];
}
는 당신에게 이벤트 "UIControlEventTouchDown"확실하거나 당신이로 눌러보십시오 평소 "UIControlEventTouchUpInside"?? –
UIControlEventTouchDown을 사용하고 있습니다. 왜냐하면 다른 게시물에서 누군가를 위해 일한 것을 보았습니다 ... 그러나 둘 다 사용하여도 여전히 작동하지 않습니다. – CainaSouza
"여전히 작동하지 않음"이란 무엇을 의미합니까? 버튼이 강조 표시되어 있지 않거나 선택자가 전혀 호출하지 않습니다. –