在互联网上搜索了很长时间,但没有得到适当的答案.我将UITableView置于编辑模式并一次选择多行.它工作得很好,但我想将复选标记的颜色从红色变为蓝色,就像在iPhone电子邮件应用程序中一样.
任何帮助,将不胜感激.
编辑版:
这是我的代码......
在我的ViewDidLoad函数中:
- (void)viewDidLoad
{
...
[deviceTableVIew setAllowsSelectionDuringEditing:YES];
[deviceTableVIew setAllowsMultipleSelectionDuringEditing:YES];
[super viewDidLoad];
}
Run Code Online (Sandbox Code Playgroud)
我有两个UIButtons,它们为tableview设置编辑模式如下:
-(IBAction)control:(id)sender{
btnControl.enabled = false;
btnControl.hidden = true;
btnCancel.enabled = true;
btnCancel.hidden = false;
stateToggleToolbar.hidden = false;
[self.deviceTableVIew setEditing:YES animated:YES];
}
-(IBAction)cancel:(id)sender{
btnCancel.enabled = false;
btnCancel.hidden = true;
btnControl.enabled = true;
btnControl.hidden = false;
stateToggleToolbar.hidden = true;
[self.deviceTableVIew setEditing:NO animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
UITableView委托方法是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//setting up the cells here
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
... …Run Code Online (Sandbox Code Playgroud) 我有一种情况,我将UITableView置于编辑模式,当它不处于编辑模式时,它必须执行tableview:didSelectRowAtIndexPath:并且必须推送到UINAvigationController.
现在的问题是如何检查UITableView是否处于编辑模式,以便不应该通过UINavigationController推送它.
iphone uitableview uinavigationcontroller didselectrowatindexpath ios
我是iPhone编程新手,陷入困境.
情况是我希望UITableView在UIButton点击进入编辑模式.进入编辑模式后,我应该在每个单元格上有一个复选框.如果我点击UIToolBarButton,我想更改已检查的单元格图像.
我怎样才能做到这一点.任何帮助,将不胜感激.
我想知道如何在不使用UITableView到其根视图控制器的情况下在UINavigationController中设置UIViewController.对此有何帮助?提前致谢.
我正在开发一个应用程序,我有一个UITableView,它使用方法tableView:cellForRowAtIndexPath:填充NSMutableArray,它工作正常,但问题是我想更改tableViewCell的图像,当我尝试访问单元格时它总是返回null.我在这里给出代码,请告诉我是否遗漏了一些东西......
在viewController.h文件中
@interface DevicesViewController : UIViewController{
IBOutlet UITableView *deviceTableVIew;
NSMutableArray *devicesArray;
NSMutableArray *deviceDetailArray;
}
@property (nonatomic,retain) IBOutlet UITableView *deviceTableVIew;
@property (nonatomic,retain) NSMutableArray *devicesArray;
@property (nonatomic,retain) NSMutableArray *deviceDetailArray;
-(IBAction)setDevicesOn:(id)sender;
-(IBAction)setDevicesOff:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
在视图controller.m文件中
-(IBAction)setDevicesOn:(id)sender{
UITableViewCell *cell = [deviceTableVIew cellForRowAtIndexPath:[NSIndexPath indexPathForRow:3 inSection:1]];
cell.imageView.image = [UIImage imageNamed:@"device-on-image.png"];
[deviceTableVIew reloadData];
...
}
-(IBAction)setDevicesOff:(id)sender{
UITableViewCell *cell = [deviceTableVIew cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
cell.imageView.image = [UIImage imageNamed:@"device-off-image.png"];
[deviceTableVIew reloadData];
...
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [devicesArray count];
}
- …Run Code Online (Sandbox Code Playgroud)