나는 내가 UIButton
(둥근을 추가 한내 UIButton이 터치에 응답하지 않는 이유는 무엇입니까?
...이 사람이 협력하지 않는 어떤 이유 ... 내가 셀 수없이 많은 작업 버튼이있어 나는이 명백한 내려다 해요 확신 ...하지만 Rect)에서 UIView
하위 클래스 (DialogView)로 이동합니다.이 뷰는 내보기 컨트롤러보기의 하위보기입니다. 이 하위보기는 거의 전적으로 IB에서 작성됩니다. IB에서 (IBAction)okButtonPressed:(id)sender
에 대한 버튼을 에 연결하고 내부를 터치하고 DialogView에서 해당 메소드를 생성했습니다. 그러나이 버튼을 "터치"하면 메서드가 실행되지 않습니다. 는이 는 true, VC의 뷰, DialogView
및UIButton
입니다 userInteractionEnabled.
어쩌면 initWithCoder
은 어떤 프레임 조작이나 무언가를해야한다고 생각했는데 콘솔에 성공적으로 기록한 다음을 추가했습니다.
- (id)initWithCoder:(NSCoder *)decoder {
if (self = [super initWithCoder:decoder]) {
NSLog(@"DialogView initWithCoder called");
}
return self;
}
추가 탐사에서 나는 버튼에
IBOutlet
을 유선 내가보기 컨트롤러에서 titleLabel을 변경하려고하면 그때는의이 심각 잘린 얻을 것을 알 수 있습니다. 처음에 그림을 그릴 때 IB에 설정된 "
Press Me!"의 기본 텍스트가 잘 표시됩니다. 나는 텍스트를 변경한다면 ...
self.DialogView.okButton.titleLabel.text = @"Not Working";
은 ... 그것은 "N이 ..."
몰라이이 관련되는 경우 잘립니다. 아마 ...
누구나 내가 여기 망쳐 버린 것을 볼 수 있을까요? 뷰 컨트롤러에서
:
편집 (UIButton
을 보여주는 관련 코드를 추가) 예상대로
self.DialogView = [[[NSBundle mainBundle] loadNibNamed:@"DialogView" owner:self options:nil] objectAtIndex:0];;
self.DialogView.myVC = self;
self.DialogView.backgroundColor = [UIColor clearColor];
self.DialogView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
self.DialogView.nameLabel.text = loan.fullName;
self.DialogView.noteLabel.text = loan.summaryOfLoan;
self.DialogView.amountLabel.text = [currencyFormatter stringFromNumber:loan.originalAmount];
self.DialogView.alpha = 0.0;
[self.view addSubview:DialogView];
UILabels 모든 표시. 문제는 그대로 UIButton
입니다. 나는 그것을 볼 수있다 나는 그것과 상호 작용할 수 없다!
DialogView의 인터페이스 :
@class MyViewController;
@interface DialogView : UIView {
IBOutlet UILabel *nameLabel, *noteLabel, *amountLabel;
IBOutlet UIImageView *arrowView;
IBOutlet UIButton *okButton;
MyViewController *myVC;
}
@property (nonatomic, retain) UILabel *nameLabel, *noteLabel, *amountLabel;
@property (nonatomic, retain) UIImageView *arrowView;
@property (nonatomic, assign) MyViewController *myVC;
@property (nonatomic, retain) UIButton *okButton;
- (IBAction)okButtonPressed:(id)sender;
@end
그리고 DialogView의 구현 :
#import "DialogView.h"
#import "MyViewController.h"
@implementation DialogView
@synthesize nameLabel, noteLabel, amountLabel, arrowView, okButton;
@synthesize myVC;
- (void)dealloc {
[nameLabel release];
[noteLabel release];
[amountLabel release];
[arrowView release];
[okButton release];
[super dealloc];
}
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
if (self = [super initWithCoder:decoder]) {
NSLog(@"DialogView initWithCoder called");
}
return self;
}
- (IBAction)okButtonPressed:(id)sender {
NSLog(@"pressed DialogView OK button");
[self.myVC.navigationController popViewControllerAnimated:YES];
}
- (void)drawRect:(CGRect)rect {
// Drawing code
}
@end
'Dialog'보기는 'MyViewController'의 유지 된 속성입니까? –
수정,''DialogView'가'MyViewController'의 유지 된 속성입니까? –
아, center \ n 속성을 설정 한 후 어떤 경계가'self.DialogView'보고입니까? –