2016-08-01 10 views
0

Bonjour mes amis je suis nouveau dans l'application iOS. J'ai utilisé la bibliothèque KGModel pour afficher les popups. Cela fonctionne bien. Mais je veux savoir comment ignorer cette popup en cliquant sur un bouton. enter image description hereComment faire pour ignorer popup KGModel en utilisant le bouton cliquez sur

Mon code est le suivant: -

#import "ViewController.h" 
#import "KGModal.h" 
#import "CRTableViewCell.h" 
@interface ViewController() 

@end 

@implementation ViewController 
{ 
NSArray *dataSource; 
bool selected; 
NSMutableArray *selectedMarks; 
UITableView *mytable; 
} 




- (void)viewDidLoad { 
[super viewDidLoad]; 


dataSource = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil]; 
selectedMarks = [NSMutableArray new]; 





    CGRect screenRect = [[UIScreen mainScreen] bounds]; 
    CGFloat screenWidth = screenRect.size.width; 
    CGFloat screenHeight = screenRect.size.height; 







     UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth-50, screenHeight-50)]; 



     UITableView *mytableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, screenWidth-50, screenHeight-100)]; 

     mytableview.delegate =self; 
     mytableview.dataSource=self; 

    [contentView addSubview:mytableview]; 


     UIButton *save = [[UIButton alloc] initWithFrame:CGRectMake(0, screenHeight-100, screenWidth-50, 50)]; 
    [save setTitle:@"SAVE" forState:UIControlStateNormal]; 
    [save setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
    [save addTarget:self action:@selector(saveAction:) forControlEvents:UIControlEventTouchUpInside]; 
    [save setBackgroundColor:[UIColor lightGrayColor]]; 
    [contentView addSubview:save]; 





     [[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES]; 


} 
     - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    { 
    return [dataSource count]; 
    } 
- (UITableViewCell *)tableView:(UITableView *)tableView  cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CRTableViewCellIdentifier = @"cellIdentifier"; 

// init the CRTableViewCell 
    CRTableViewCell *cell = (CRTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CRTableViewCellIdentifier]; 

    if (cell == nil) { 
    cell = [[CRTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CRTableViewCellIdentifier]; 
} 


    NSString *text = [dataSource objectAtIndex:[indexPath row]]; 
    cell.textLabel.font = [UIFont systemFontOfSize:12.0]; 
    cell.isSelected = [selectedMarks containsObject:text] ? YES : NO; 
cell.textLabel.text = text; 
mytable=tableView; 
return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath 
{ 
NSString *text = [dataSource objectAtIndex:[indexPath row]]; 

if ([selectedMarks containsObject:text])// Is selected? 
    [selectedMarks removeObject:text]; 
else 
    [selectedMarks addObject:text]; 

    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 

} 
-(void)saveAction:(id)sender{ 
NSLog(@"%@",sender); 
selected = !selected; 
NSLog(@"%lu",[dataSource count]); 
for(int i=0; i<[dataSource count]; i++){ 
    NSString *text = [dataSource objectAtIndex:i]; 
    if(selected){ 

     [selectedMarks addObject:text]; 
    }else{ 
     [selectedMarks removeObject:text]; 
    } 

} 
    [mytable reloadData]; 
    KGModal *model = [[KGModal alloc]init]; 
    [model hideAnimated:YES withCompletionBlock:nil]; 
      //NSLog(@"%@", selectedMarks); 
    } 

Je veux fermer cette fenêtre en cliquant sur la sauvegarde button.Please me aider.

+0

peut vous montrer le code ur essayé –

Répondre

0

si youwant pour fermer le KGModel en utilisant Save bouton utiliser le code suivant dans votre bouton l'action

[KGModal sharedInstance].animateWhenDismissed = YES; 

vous pouvez voir la propriété dans here

// Determines if the modal should dismiss if the user taps outside of the modal view 
// Defaults to YES 
@property (nonatomic) BOOL tapOutsideToDismiss; 

// Determines if the close button or tapping outside the modal should animate the dismissal 
// Defaults to YES 
@property (nonatomic) BOOL animateWhenDismissed; 

// Determins close button type (None/Left/Right) 
// Defaults to Left 
+0

Merci pour votre réponse, mais il ne fonctionne pas karthik –

+0

ne fonctionne sûrement, pouvez-vous mettre à jour la question –

+0

Merci Karthik maintenant son travail par ce code "[[KGModal sharedInstance] hideAnimated: YES];" –