为什么我的uitableview不会保存更改

时间:2015-04-21 00:18:35

标签: ios objective-c uitableview

我正在学习一些xcode并从朋友那里挖掘一些预制代码,并且我的一个表格视图并没有在完​​成后保存更改。我附上了一个显示发生了什么的gif。我从列表中取消选择两项运动,然后按完成,返回页面并重新检查两项运动。我已粘贴下面的代码。

https://imgflip.com/gif/kftqf

- (IBAction)btnSelectSportsClicked:(id)sender {
    UIButton *btnSelectSportClicked = (UIButton *)sender;
    btnSelectSportClicked.enabled = NO;
    double delayInSeconds = 1.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            btnSelectSportClicked.enabled = YES;
    });
    self.sporttype = @"sport";
    self.tempSports = self.Sportsstring;
    self.Sports = [[[GlobalData sharedInstance] loadSports] mutableCopy];

    NSMutableDictionary *Data = [[NSMutableDictionary alloc] init];
    [Data setObject:self.sporttype forKey:@"SportType"];
    [Data setObject:self.tempSports forKey:@"tempsport"];
    [Data setObject:self.Sports forKey:@"sport"];
    [Data setObject:@"yes" forKey:@"isAllowSelection"];
    self.sportSelectionview =  [[[NSBundle mainBundle] loadNibNamed:@"SportSelectionView" owner:self options:nil] objectAtIndex:0];
    [self.sportSelectionview setDelegate:self];
    [self.sportSelectionview initdata:Data];
    CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    [self.view addSubview:self.sportSelectionview];
    [self.sportSelectionview setFrame:CGRectMake(0, screenSize.height, screenSize.width, screenSize.height)];

    [UIView animateWithDuration:0.5f
                     animations:^{
                         [self.sportSelectionview setFrame:CGRectMake(0, 0, screenSize.width, screenSize.height)];
                     }];

}

-(void)btnDoneClicked:(id)sender selectedData:(NSMutableDictionary *)selected
{

    CGSize screenSize = [[UIScreen mainScreen] bounds].size;
    [self.sportSelectionview setFrame:CGRectMake(0, 0, screenSize.width, screenSize.height)];

    [UIView animateWithDuration:0.5f
                 animations:^{
                     [self.sportSelectionview setFrame:CGRectMake(0,  screenSize.height, screenSize.width, screenSize.height)];

                 }completion:^(BOOL finished){

                     [self.sportSelectionview removeFromSuperview];
                 }];

    if([self.sporttype isEqualToString:@"sport"]){
        self.Sportsstring = [selected objectForKey:@"sports"];
    }else{
        self.BusinessSportsstring = [selected objectForKey:@"sports"];
    }
    NSLog(@"Sportstring :%@  BusinessSport : %@",self.Sportsstring ,self.BusinessSportsstring);
}

0 个答案:

没有答案