Tag: 可用视图

选中并取消选中相同的UITableViewCell

我需要取消选中我的tableView中的单元格。 就像一个checkbox,一旦我按下一个单元格它保持选中,如果我再次按下同一个单元格,它保持未选中状态。 可能吗? 我发现的一切是取消select细胞的方法 [table deselectRowAtIndexPath:NSIndexPath animated:YES]; 但没有用处 upd:我不需要检查多个单元格,我需要取消选中单元格,如果点击选中的单元格,并且如果我点击其他(未选中的)单元格,select应该将状态更改为未选中状态(单元格中它已经默认工作)

为什么不如果(cell == nil)工作?

我试图使用几个不同的重用标识符,让用户能够input数据没有segue …(只是认为这将是很好的)。 这是我第一次尝试: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if(addC && indexPath.row == 0 && indexPath.section == 0){ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; UITextField *txtField = [[UITexField alloc] initWithFrame:CGRectMake(10, 7, 260, 30); [cell addsubview:txtField]; cell.txtField.delegate = self; cell.txtField.text = nil; return cell; 但是,我注意到,如果我不止一次地使用该字段,那么文本字段将会重复,而在下面留下旧的值。 所以经过一番研究,我补充道: if(cell == nil){ } 围绕txtField初始化,但不会触发。 我结束了解决这个问题完全通过制作一个单独的UITableViewCell类,但现在我正在尝试添加SWTableViewCell ,并将我的单元格从UITableViewCell更改为CustomTableViewCell。 这个自定义实用程序插件到我的表和初始化需要你使用 if (cell == […]

在iOS中跳过/忽略方法

如何跳过iOS中的完整方法? 我知道如何testing一个方法内的iOS版本,但不知道如何完全忽略一个方法。 具体的例子:iOS8添加了自定义表格视图单元格,并且不再需要方法heightForRowAtIndexPath:和estimatedHeightForRowAtIndexPath: :。 但是我确实需要iOS7。 现在,当我逐步浏览iOS8中的代码时,即使不再需要,也会调用这两种方法。

如何保存uitableview中的复选标记,并在用户再次返回到视图时显示它们?

我正在使用下面的代码来显示uitableview中的复选标记 { // NSArray *tableContents; NSMutableArray *selectedMarks; // You need probably to save the selected cells for use in the future. } @property (strong, nonatomic) IBOutlet UITableView *languageTableView; @property (nonatomic, strong) NSArray *tableContents; @end @implementation QPLanguageSettingsController – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self initialisation]; selectedMarks = [NSMutableArray […]

获取重新sorting的UITableViewCells的顺序

我正在尝试将单元格的重新sorting索引放入数组中。 在viewDidLoad cell.showsReorderControl = YES; arrayTag = [NSMutableArray array]; //创build单元格时将indexPath.row另存为cell.tag。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ….. cell.tag = indexPath.row; NSString *strCellTag = [NSString stringWithFormat:@"%d",cell.tag]; if(![arrayTag containsObject:strCellTag]) { [arrayTag addObject:strCellTag]; } return cell; } / /我不知道这是正确的方式,但下面我试图保存对数组的更改。 – (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath { [arrayTag replaceObjectAtIndex:sourceIndexPath.row withObject:[NSString stringWithFormat:@"%i",proposedDestinationIndexPath.row]]; [arrayTag replaceObjectAtIndex:proposedDestinationIndexPath.row withObject:[NSString stringWithFormat:@"%i",sourceIndexPath.row]]; return […]

如何区分UITableView自定义部分点击和部分第一行点击?

UITableView返回相同的callback“ didSelectRowAtIndexPath ”与相同的NSIndexPath (0,0)节点击和节第一行单击。 我使用自定义视图的部分标题视图,我需要对这些部分行执行一些操作。 尝试使用[tableView cellForRowAtIndexPath:indexPath]检查单元类,但它显然返回相同的行单元,而不是部分单元格。 有什么build议么? 更新我可以将我的自定义部分视图添加到第一行,而不是将其添加为一个部分,但是在这种情况下,我需要返回不同的行高度在“ heightForRowAtIndexPath ”,这将不是表演明智的决定。 更新我已经devise了我的部分视图作为UITableViewCell的子类,因为我更喜欢本机UITableViewcallback,而不是解决方法与轻拍手势或button。

将存储在NSArray中的图像添加到UITableView

首先,我是编程新手,我试图创build一个具有UITableView的应用程序,并显示存储在数组中的名称,并在每个名称之外显示图像(图标)。 我已经添加了三个图像,并命名为1.jpg , 2.jpg和3.jpg 。 该应用程序运行良好,但告诉应用程序后,我想要显示的数组中存储的图像和运行的应用程序的iOS模拟器的工作,但然后我在我的main.m文件中得到一个绿色的错误? 以下是我的实现文件: NSMutableArray *myImages; NSMutableArray *myNames; @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. myNames = [[NSMutableArray alloc ]initWithObjects:@"A",@"B",@"C", nil]; for (int imageNumber =1 ; imageNumber <= 3; imageNumber++) { myImages= [[NSMutableArray alloc]initWithObjects:[[NSString stringWithFormat:@"%i.jpg", imageNumber ]], nil]; } […]

删除button在UITableview的编辑模式下滚动消失

我在编辑模式下滚动tableview时遇到问题。 这是因为细胞的可重用性。 我在编辑模式下的链接UITableView – 滚动删除buttonDissapears 没有从这一点。 这是我的代码片段 – – (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; [tableView setEditing:editing animated:animated]; [tableView setAllowsMultipleSelectionDuringEditing:editing]; } – (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleDelete; } – (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { return NO; } – (BOOL)tableView:(UITableView *)tableview canMoveRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { […]

出现键盘时偏移UITableView内容

嗨我得到的错误:属性'editingIndexPath'没有find对象的types'ViewController *'与行: [self.tableView scrollToRowAtIndexPath:self.editingIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; 这个错误与这个调用有关: self.editingIndexPath 我将如何解决这个错误? – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } – (void)keyboardWillShow:(NSNotification *)notification { CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; UIEdgeInsets contentInsets; if (UIInterfaceOrientationIsPortrait([[UIApplication […]

如何避免UITableViewCell重复添加自定义标签时,TableView滚动?

我创build一个自定义单元格: #import <UIKit/UIKit.h> #import "RecruitmentResumeEntity.h" @interface RecruimentListItemCell : UITableViewCell @property (nonatomic, strong) RecruitmentResumeEntity *entity; @end 在.m文件中设置实体方法我添加三个标签: -(void)setEntity:(RecruitmentResumeEntity *)entity { _entity = entity; float labelHeight = 17; CGRect frame = CGRectMake(64, 45, 0, labelHeight); UILabel *cityLabel = [self createTagLabelWithFrame:frame text:_entity.city backgroundColor:@"#e5986f"]; [self.contentView addSubview:cityLabel]; UILabel *workExperienceLabel = [self createTagLabelWithFrame:CGRectMake(cityLabel.x+cityLabel.width +10, cityLabel.y, 0, labelHeight) text:[NSString stringWithFormat:@"%@年",_entity.workExperience] backgroundColor:@"#81A0D7"]; [self.contentView […]