2014-11-01 3 views
0

Parse anypic tutorial을 사용하고 있으며 다른 UI를 만들고 싶습니다. 하지만 몇 가지 문제가 있습니다.배경을 추가 할 때 버튼을 사용할 수 없습니다.

@interface PAPHomeViewController() 
@property (nonatomic, strong) PAPSettingsActionSheetDelegate *settingsActionSheetDelegate; 
@property (nonatomic, strong) UIView *blankTimelineView; 
@end 

@implementation PAPHomeViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    NSLog(@"LoadView is called"); 

    // Present Anypic UI 
    [self presentUI]; 

} 

-(void) presentUI { 

/*UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
     [backgroundImageView setImage:[UIImage imageNamed:@"DefaultAnypic.png"]]; 
     self.view = backgroundImageView;*/ 

    // Settings button 
    self.settingsButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    [self.settingsButton addTarget:self 
       action:@selector(settingsButtonAction:) 
    forControlEvents:UIControlEventTouchUpInside]; 
    [self.settingsButton setTitle:@"Settings" forState:UIControlStateNormal]; 
    self.settingsButton.frame = CGRectMake(200.0, 200.0, 100.0, 100.0); 
    [self.view addSubview:self.settingsButton]; 
} 

하고 .H 파일은 다음과 같습니다 :

그래서, 내의 ViewController이있다

@interface PAPHomeViewController : PAPPhotoTimelineViewController 

@end 

PAPPhotoTimelineViewController 또한 홈에서 확장하는 separateViewController이고, 그것은 tableViewController입니다 또한 ViewDidLoad를 호출합니다.

는 문제 : 위의 코드와

, 내 버튼을보고 내 버튼을 클릭 할 수 있습니다.

배경에 대한 주석 처리를 제거하면 배경이 보입니다. 버튼이 보이지만 클릭 할 수 없습니다. 버튼에 아무런 터치가없는 것처럼 보입니다.

나는 또한 지금은 또한이 둘 다라고하는 이유의 viewDidLoad을 구현 서로의 ViewController을 확장하고 있음을, 혼란 스러워요하는 등의 순서로

답변

2

당신은 당신의 self.view에 새 UIView를 할당해서는 안됩니다.

self.view = backgroundImageView; 대신 임의의보기처럼 추가하십시오. 당신의 backgroundImageView이보기에 표시됩니다, 그리고 버튼이 그 위에 추가됩니다 것을 이렇게

[self.view addSubview:backgroundImageView]; 

, 당신은 하위 뷰를 추가 할 수있는 올바른 방법을 따릅니다.

+0

내 하루를 저장했습니다. 자격을 얻는 데 수 분 내에 수락 할 것입니다. – ghostrider

관련 문제