내 설정 페이지에 UISwitchController가있어 메인 page.so에서 이미지를 바꿀 수 있습니다. 페이지를 먹는 페이지의 알림을 기본 페이지에 넣습니다. 그러나 매번 활성화되는 알림, 설정 페이지 전환 코드보기 내 주요 page.h..i이NSnotifiaction 의문의 여지가
-(IBAction)_clickswitchlowlight:(id)sender
{
if(switchControll.on){
[switchControll setOn:YES animated:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_lowlighton object:nil];
}
else{
[switchControll setOn:NO animated:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIF_lowlightoff object:nil];
}
}
처럼이
NSString * const NOTIF_lowlighton = @"lowlighton";
NSString * const NOTIF_lowlightoff = @"lowlightoff";
쓰기
메인 페이지의 이행을 위하는 .m에서
extern NSString * const NOTIF_lowlighton;
extern NSString * const NOTIF_lowlightoff;
이 코드를 작성 viewwillappear에서
나는 다음이 코드
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clicklowlighton:) name:@"lowlighton" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clicklowlightoff:) name:@"lowlightoff" object:nil];
}
이미지
- (void)clicklowlighton:(NSNotification *)notif
{
[[self multiPageView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bgipad"]]];
}
- (void)clicklowlightoff:(NSNotification *)notif
{
[[self multiPageView] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"[email protected]"]]];
}
변경이 코드를 작성 나는 단지 clicklowlightoff 통지를 얻을, 나는 어떤 실종 ... 최초의 통지를하지 않았다 내 코드? 덕분에 . 이벤트에 함수 바인딩
왜 스위치의 상태를 변경하려면 UIControlEventValueChanged? [switchControll setOn : YES animated : YES]; ?? –
@Ubersoldat이 (가) 켜져 있는지 확인합니다. 오류입니까? – stackiphone
아니요, 이미 "켜짐"상태에서 "켜기"로 설정하려고합니다. 왜? –