目标C- actionSheetPickerView用于自定义单元格上的textField

时间:2016-02-19 10:52:23

标签: ios uipickerview uiactionsheet

我正在我的计划上实施ActionSheetPickerView但是当我尝试选择ActionSheetStyleTextPicker时,PickerView中没有任何内容,但ActionSheetStyleDatePicker的相同代码正在运行,我能够选择日期。

我在我的程序中使用 IQActionSheetPickerView github.com/hackiftekhar/IQActionSheetPickerView

在我的tableView我写了这段代码

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCell *cell=(CustomCell *)[ProfileTable dequeueReusableCellWithIdentifier:@"Cell"];
        if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomeCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    if (indexPath.section==0) {
if ([[[ProfileTableArray objectAtIndex:indexPath.row] valueForKey:@"DT"]isEqualToString:@"D"]) {

    IQActionSheetPickerView *picker = [[IQActionSheetPickerView alloc] initWithTitle:@"Date Picker" delegate:self];
    [picker setActionSheetPickerStyle:IQActionSheetPickerStyleDatePicker];
    [picker setTag:1];
    //[picker show];
    [cell.SInfoTxt setInputView:picker];
} else {
     IQActionSheetPickerView *picker = [[IQActionSheetPickerView alloc] initWithTitle:@"Single Picker" delegate:self];
     [picker setTitlesForComponenets:customDValues];
     [picker setTag:2];
     [picker setActionSheetPickerStyle:IQActionSheetPickerStyleTextPicker];
     //[picker show];
     [cell.SInfoTxt setInputView:picker];
    }
}

我已经为textPicker或DatePicker写了这个

-(void)actionSheetPickerView:(IQActionSheetPickerView *)pickerView didSelectTitles:(NSArray *)titles
{
    switch (pickerView.tag)
    {
        case 1:{
            NSString * dateStr =[NSString stringWithFormat:@"%@",[titles objectAtIndex:0]];

                NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
                [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];
                NSDate *toDateTime = [dateFormat dateFromString:dateStr];               
                NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                [dateFormatter setDateFormat:@"dd MMM yyyy"];
                NSString *stringDate = [dateFormatter stringFromDate:toDateTime];
                [(UITextField *)[self.view viewWithTag:tag] setText:stringDate];
                [self.view endEditing:YES];
            break;
        }
        case 2: {

       //here i want to show my NSArray which was am already stored in array
       // so how can i call Textpicker here..??
                break;
        }
}

0 个答案:

没有答案