0
내 alterView에서 버튼을 클릭 한 후 액션을 시작하려고합니다.하지만 아무 일도 일어나지 않습니다 .-(같은 viewController에서 여러 옵션이있는 actionSheet를 사용합니다.이 actionsSheet는 완벽하지만 alertView는 작동하지 않습니다.UIAlertView - 아무런 조치가 필요 없습니다. 왜?
여기 내 코드입니다 Dubug에 오류가 없습니다 감사 ????? 잘못 무엇 헤더에
:..!있는 viewDidLoad에서
#define alertWelcome 1
#define alertFacebook 2
#define alertRecommend 3
:
if (! hasRanBefore) {
NSLog(@"else has ran before");
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"Headline_firstLaunch", @"Headline")
message:NSLocalizedString(@"firstLaunch", @"1.Start - Hilfe") delegate:self
cancelButtonTitle:NSLocalizedString(@"no",@"No")
//defaultButton:@"OK"
//alternateButton:@"Cancel"
otherButtonTitles:/*NSLocalizedString(@"Facebook",@"Login"),*/ nil];
alert.tag = alertWelcome;
[alert show];
[alert release];
}
[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(fbLogin:) userInfo:nil repeats:NO];
내 방법 :
- (void)fbLogin:(id)sender{
NSLog(@"FB Login Alert");
if (![facebook isSessionValid]) {
UIAlertView *popupFacebook = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"Headline_FacebookL", @"Headline")
message:NSLocalizedString(@"Facebook-Text", @"1.Start - Hilfe")
delegate:self
cancelButtonTitle:NSLocalizedString(@"no",@"No")
//defaultButton:@"OK"
//alternateButton:@"Cancel"
otherButtonTitles:NSLocalizedString(@"Facebook",@"Login"), nil];
// [popupFacebook addButtonWithTitle:NSLocalizedString(@"Facebook",@"Login")];
popupFacebook.tag = alertFacebook;
[popupFacebook show];
[popupFacebook release];
}
}
내 방법 :
//First View Alert
-(void)firstActionSheet:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"clicking");
//NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex];
if (alertView.tag == alertWelcome) {
if (buttonIndex == 0) {
NSLog(@"close");
}
}
else if (alertView.tag == alertFacebook) {
if (buttonIndex == 0) {
NSLog(@"später");
}
if (buttonIndex == 1) {
//self.label.text = NSLocalizedString(@"Facebook",@"Login"),
[self fbActive:nil];
NSLog(@"Login to FB");
}
}
}
완벽한 실행 actionSheet :
-(IBAction)inviteFriends:(id)sender {
UIActionSheet *popupQuery = [[UIActionSheet alloc]
initWithTitle:NSLocalizedString(@"invite_Headline",@"Erzähle es Deinen Freunden:")
delegate:self
cancelButtonTitle:NSLocalizedString(@"invite_cancel",@"Abbrechen")
destructiveButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"invite_eMail",@"per E-Mail einladen"),
NSLocalizedString(@"invite_SMS",@"per SMS einladen"),
NSLocalizedString(@"vote",@"App bewerten"),
/*NSLocalizedString(@"invite_Facebook",@"Facebook"),*/
NSLocalizedString(@"invite_Twitter",@"Twitter"), nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
popupQuery.tag = alertRecommend;
[popupQuery showInView:self.view];
[popupQuery release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
UIDevice* currentDevice = [UIDevice currentDevice];
if(currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
NSLog(@"oh its iPad");
if (buttonIndex == 0) {
self.label.text = NSLocalizedString(@"invite_eMail",@"per E-Mail einladen"),
[self showMailPicker:nil];
}
else if (buttonIndex == 1) {
self.label.text = NSLocalizedString(@"vote",@"App bewerten"),
[self bewerten:nil];
}
else if (buttonIndex == 2) {
self.label.text = NSLocalizedString(@"invite_Twitter",@"Twitter"),
[self twitter:nil];
}
/*else if (buttonIndex == 3) {
self.label.text = NSLocalizedString(@"invite_cancel",@"Abbrechen");
}*/
}
else{
NSLog(@"This is iPhone");
if (buttonIndex == 0) {
self.label.text = NSLocalizedString(@"invite_eMail",@"per E-Mail einladen"),
[self showMailPicker:nil];
NSLog(@"Mail");
} else if (buttonIndex == 1) {
self.label.text = NSLocalizedString(@"invite_SMS",@"per SMS einladen"),
[self sendInAppSMS:nil];
} else if (buttonIndex == 2) {
self.label.text = NSLocalizedString(@"vote",@"App bewerten"),
[self bewerten:nil];
} //else if (buttonIndex == 3) {
//self.label.text = NSLocalizedString(@"invite_Facebook",@"Facebook"),
//[self facebook_invite:nil];
// }
else if (buttonIndex == 3) {
self.label.text = NSLocalizedString(@"invite_Twitter",@"Twitter"),
[self twitter:nil];
} /*else if (buttonIndex == 4) {
self.label.text = NSLocalizedString(@"invite_cancel",@"Abbrechen");
}*/
}
}
'firstActionSheet : clickedButtonAtIndex :'라는 메소드가 있습니다. 그건 오타예요? (델리게이트 메소드는'alertView : clickedButtonAtIndex :'라고 가정합니다.) –
죄송 합니다만, 나는 이해하지 못했습니다 .. 그래서 alertheet라는 actionheet를위한 메소드를 가지고 있습니다. 그러나 alterView에서 내 probelm을 이해하지 못합니다. – webschnecke
The 귀하가 게시 한 코드에는 - (void) firstActionSheet : (UIAlertView *) alertView clickedButtonAtIndex : (NSInteger) buttonIndex {'시작하는 메소드가 포함되어 있습니다. 요점은 위임 메서드의 이름이 아니라는 것입니다. –