2015-10-07 15 views
5

mi colpisce in un problema in cui ho bisogno di attuare un multiplo selettore di selezione del tipo così per questo scopo sto facendo questo:UITableView all'interno UIPickerView in iOS

caratFromPicker = [[UIPickerView alloc] init]; 
    caratTable = [[UITableView alloc]initWithFrame:caratFromPicker.frame style:UITableViewStylePlain]; 
    caratTable.delegate = self; 
    caratTable.dataSource = self; 
    caratTable.bounces = YES; 

    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done)]; 
    UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-caratFromPicker.frame.size.height-50, self.view.frame.size.width, 50)]; 
    [toolBar setBarStyle:UIBarStyleBlackOpaque]; 
    NSArray *toolbarItems = [NSArray arrayWithObjects:doneButton, nil]; 
    [toolBar setItems:toolbarItems]; 
    price1.inputView = caratFromPicker; 
    price1.inputAccessoryView = toolBar; 
    [caratFromPicker setDataSource: self]; 
    [caratFromPicker setDelegate: self]; 
    caratFromPicker.showsSelectionIndicator = YES;//loadFromPicker 
    [caratFromPicker addSubview:caratTable]; 

e implementato i delegati UITableView come:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 
    return 1; 
} 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
    return [caratFromArray count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

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

    tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

    cell.textLabel.text = [caratFromArray objectAtIndex:indexPath.row]; 

    return cell; 
} 

ecco lo screenshot della stessa: enter image description here

ma il mio problema è che non sono in grado di scorrere la Tableview a guarda i prossimi valori.

+2

prima della risposta alla domanda quello che ottieni è una modifica da parte di qualcuno :) :) :) –

+0

hahahhahaha ..... Cunei di agente fantastico .... !!! thats true – user2998990

+0

Perché stai mettendo una vista tabella all'interno di una vista di selezione? Questo sembra molto insolito. Puoi fornire alcuni screenshot di ciò che stai cercando di ottenere? –

risposta

0

Puoi provare a utilizzare metodo delegato UIPicker:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)theView{ 
    return YourTableView; 
} 

Per impostare tableView come la vista per la fila.

Problemi correlati