alterViewのボタンをクリックした後、アクションを開始しようとしましたが、何も起こりません;-(同じviewControllerで、いくつかのオプションを備えたactionSheetを使用します-このactionsSheetは完全に機能しますが、alertViewは機能しません。
これが私のコードです。Dubugにはエラーはありません。なにが問題ですか?????ありがとう!
ヘッダー内:
#define alertWelcome 1
#define alertFacebook 2
#define alertRecommend 3
ViewDidLoadの場合:
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");
}
}
}
完璧なランニングアクションシート:
-(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");
}*/
}
}