小编Age*_*ks.的帖子

iOS中的UIPickerView内的UITableView

我很困惑,我需要实现一个多类型选择选择器,所以为此我正在这样做:

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];
Run Code Online (Sandbox Code Playgroud)

并将UITableView委托实现为:

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

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

- (UITableViewCell *)tableView:(UITableView …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c uitableview ios

5
推荐指数
1
解决办法
565
查看次数

标签 统计

ios ×1

iphone ×1

objective-c ×1

uitableview ×1

xcode ×1