저는 iOS 개발자의 초보자입니다. 특정 필드의 변수에 따라 하나의 버튼과 관련된 두 가지 결과가있는 간단한 응용 프로그램을 작성하려고합니다.xcode는 액션 장면에서 버튼에 액션을 연결합니다.
사용자가 내 앱에서 Walk 버튼을 누르고 상태 (변수)가 Jumping이면 액션 장면이 나타납니다.
상태가 점프하고 사용자 프레스는 다음과 같은 장면이 다음 코드를 기반으로 팝업, 도보 경우
- (IBAction)walk:(id)sender {
if ([_personState.text isEqual: @"Jumping"])
{
UIActionSheet *actionsheet = [[UIActionSheet alloc]
initWithTitle:@"Invalid Action - Force?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Force", nil];
[actionsheet showInView:self.view];
}
else {_personState.text = @“Walking";}
} 내가 힘을 클릭하면 personState이 걷기에 업데이트되지 않습니다
.
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if ([_personState.text isEqual: @"Jumping"] && buttonIndex == 0)
{
_personState.text = @"Walking";
}
if 문이 올바르지 않습니까? 아니면 다른 오류가 있습니까?
두려워하지 않습니다. 상태는 그대로입니다. – lostinthebits