我做了一个应用程序,它具有从相机捕获图像和点击按钮的按钮,pickerView将通过操作表显示并选择图像类型(jpg,png,bmp ..),一旦选择从选择器,按钮标题将根据pickerView结果改变,uItableviewcell动态检索值
然后我尝试将此转换为UITableView的,其具有用于图像选择的图像的类型2部分(1和1,
现在我'有问题,我尝试imageView到单元格中,但图像重叠其他单元格,并且一旦图像捕获从相机imageView未更新,但一旦滚动表格,只有更新,
的另一个问题是,一旦选择第二部分我能够调用pickerView选择图像类型如以前,但一旦从pickerView选择我没怎么更新cell.text
下面是我的代码,任何人都可以在这里帮助或改善它,
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
switch (section) {
case 0:
return NSLocalizedString(@"Image", @"");
break;
case 1:
return NSLocalizedString(@"Image type", @"");
break;
default:
break;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];
}
switch (indexPath.section) {
case 0:
{
UIImageView *abc = [[UIImageView alloc] initWithFrame:CGRectMake(5,5,100,100)];
abc.image = imageView.image;
[cell addSubview:abc];
}
break;
case 1:
cell.textLabel.text = @"- Click here -";
break;
default:
break;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"Cell"] autorelease];
}
if(indexPath.section == 0) {
NSLog(@"selected %d",indexPath.section);
}
if(indexPath.section == 1) {
NSLog(@"selected %d",indexPath.section);
[self chooseType];
}
}
- (void)chooseType{
actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
NSArray *typeObject = [NSArray arrayWithObjects:@".jpg",@".png",@".bmp",nil];
self.pickerData = typeObject;
pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, 0.0, 0.0)];
pickerView.delegate = self;
pickerView.showsSelectionIndicator = YES;
pickerDateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerDateToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerDateToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(TypeDonePick)];
[barItems addObject:doneBtn];
[pickerDateToolbar setItems:barItems animated:YES];
[actionSheet addSubview:pickerDateToolbar];
[actionSheet addSubview:pickerView];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0,0,320, 464)];
[pickerView release];
[actionSheet release];
}
- (void)TypeDonePick
{
NSInteger row = [pickerView selectedRowInComponent:0];
titleCause.textColor = [UIColor blackColor];
titleCause.text = [pickerData objectAtIndex:row];
NSLog(@" %@ ",titleCause.text);
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
}
是有可能电池测试从外部范围UITable功能
感谢
请编辑您的帖子把代码中的代码标记,使我们可以更容易地阅读它。 – 2010-01-26 06:53:26