2016-05-23 1 views
0

Je veux montrer une ActionSheet pour montrer un compte créer sur la carte Je peux implémenter ceci dans ipad en utilisant la méthode ShowFromRect mais le comportement de ShowFromRect n'est pas défini pour Iphone ou il a un défaut bahaviour, c'est-à-dire qu'il apparaît du bas de la vue, mais je veux montrer la feuille d'action sur la carte partout où l'utilisateur clique sur la carte. Comment puis-je l'implémenter? Ou est-ce comme si je devais créer un UIView personnalisé comme le UIActionSheet avec la flèche pointant vers l'emplacement que l'utilisateur sélectionne sur la carte. Si oui, comment puis-je créer un UIView personnalisé à cette fin? J'ai joint une image de démonstration pour montrer à quoi je veux ressembler.Créer un uiView personnalisé comme UiActionSheet dans ios

Répondre

0

peut être cette solution vous aider ... j'ai lu quelque part .. Vous pouvez le faire en utilisant une feuille d'actions. Déclare d'abord une propriété de uiactionsheet à l'interface. Dans l'exemple ci-dessous, j'ai déclaré une propriété appelée countryActionSheet.

après que dans le IBaction suivre le code;

-(IBAction)popupView{// declare another actionSheet // 
UIActionSheet *actionSheet =[[UIActionSheet alloc]initWithTitle:@"Select Country"  delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles: nil]; 

countryActionsheet=actionSheet;//equate both the actionSheets// 

actionSheet.actionSheetStyle= UIActionSheetStyleBlackTranslucent; 
countryPicker.dataSource=self; 
countryPicker.delegate=self; 

// Add your view with frame with respect to actionSheet// 

UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 400)]; 
imageView.image=[UIImage imageNamed:@"black background.png"]; 

UIButton *cancelBtn=[[UIButton alloc]initWithFrame:CGRectMake(200,20, 80, 30)]; 
[cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal]; 
[cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
[cancelBtn addTarget:self action:@selector(cancelBtnPressed) forControlEvents:UIControlEventTouchUpInside];// create a method named cancelBtnPressed 
[cancelBtn setBackgroundImage:[UIImage imageNamed:@"Untitled 4.png"] forState:UIControlStateNormal]; 

UIButton *okBtn =[[UIButton alloc]initWithFrame:CGRectMake(40, 20, 80, 30)]; 
[okBtn setTitle:@"Done" forState:UIControlStateNormal]; 
[okBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
[okBtn addTarget:self action:@selector(okBtnPressed) forControlEvents:UIControlEventTouchUpInside];// create method named okBtnPressed 
[okBtn setBackgroundImage:[UIImage imageNamed:@"Untitled 4.png"] forState:UIControlStateNormal]; 


[countryActionsheet addSubview:imageView]; 
[countryActionsheet addSubview:cancelBtn]; 
[countryActionsheet addSubview:okBtn]; 

[countryActionsheet showInView:self.view]; 
[countryActionsheet setBounds:CGRectMake(0, 0, 320, 400)];// frame of actionSheet 
} 

-(void)cancelbtnPressed{ 
    // write action 
} 

-(void)okBtnPressed{ 
    // write action 
} 

espoir que cela pourrait vous aider;

+0

Qu'est-ce qu'un sélecteur de pays dans le code ci-dessus? – Nikhil

+0

@property (nonatomic, fort) UIPickerView * countryPicker; .... @ Nikhil –

+0

laissez-moi savoir .. avez-vous résolu votre problème ou non .. @ Nikhil –