GVKun编程网logo

iOS 双击 TabBar 移动至未读消息 cell

4

对于想了解iOS双击TabBar移动至未读消息cell的读者,本文将提供新的信息,并且为您提供关于Cell高度自适应SDAutoLayout-Cell、Cell.add“CellContent”在It

对于想了解iOS 双击 TabBar 移动至未读消息 cell的读者,本文将提供新的信息,并且为您提供关于Cell 高度自适应 SDAutoLayout-Cell、Cell.add“ Cell Content”在Itext7版本7.1.12中不起作用是我还是Itext7提供的?这是一些代码、Excel添加多个单元格的注释报错:Multiple cell comments in one cell are not allowed, cell: A1、iOS - 关于 Cell 上 Button 点击效果 Cell添加Button点击无效果处理的有价值信息。

本文目录一览:

iOS 双击 TabBar 移动至未读消息 cell

iOS 双击 TabBar 移动至未读消息 cell


- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
    NSDate * currentDate = [NSDate new];
    BaseNavigationController * nav = tabBarController.selectedViewController;//获取TabBar
    if (([nav.viewControllers.firstObject isKindOfClass:[self class]]) && (currentDate.timeIntervalSince1970 - self.lastDate.timeIntervalSince1970) <= 0.5) {//根据两次点击事件判断
        [self doubleSelectTabbar];
    }
    if ([nav.viewControllers.firstObject isKindOfClass:[self class]]) {
        self.lastDate = currentDate;//赋值第一次点击
    }
    
    return  true;
}

- (void)doubleSelectTabbar{
//由于项目需求做了frame修改
    CGRect temp = self.tableView.frame;
    temp.origin.y = 0;
    self.tableView.frame = temp;
    tableViewCell *firstCell = [self.tableView visibleCells].firstObject;//显示的第一个cell
    NSIndexPath *firstCellIndex = [self.tableView indexPathForCell:firstCell];//显示cell的indexpath
    
    tableViewCell *lastCell = [self.tableView visibleCells].lastObject;//显示的最后一个cell
    NSIndexPath *lastCellIndex = [self.tableView indexPathForCell:lastCell];//显示的最后一个cell的indexpath
    
    if (firstCellIndex.row < self.conversations.count-1 && lastCellIndex.row < self.conversations.count-1) {
        for (NSInteger i = firstCellIndex.row+1; i < self.conversations.count; i++) {
            DataModel *lastModel = self.conversations[i];
            if (lastModel.unreadCount.unread>0) {//是否有未读消息
                self.currentCellIndex = [NSIndexPath indexPathForRow:i inSection:0];//移动至top
                [self toScrollPosition];
                CGRect temp = self.tableView.frame;
                temp.origin.y = temp.origin.y + ( kIs_iPhoneX ? 16 : -8);
                self.tableView.frame = temp;
                break;
            }else{
                
                for (NSInteger i = 0; i < self.conversations.count; i++) {//重新开始移动cell
                    DataModel *lastModel = self.conversations[i];
                    if (lastModel.unreadCount.unread>0) {
                        self.currentCellIndex = [NSIndexPath indexPathForRow:i inSection:0];
                        [self toScrollPosition];
                        break;
                    }
                }
            }
        }
    }else{
        for (NSInteger i = 0; i < self.conversations.count; i++) {//没有data
            DataModel *lastModel = self.conversations[i];
            if (lastModel.unreadCount.unread>0) {
                self.currentCellIndex = [NSIndexPath indexPathForRow:i inSection:0];
                [self toScrollPosition];
                break;
            }
        }
    }

    temp.origin.y = temp.origin.y + ( kIs_iPhoneX ? 16 : -8);
    self.tableView.frame = temp;

}



- (void)toScrollPosition{
    [self.tableView scrollToRowAtIndexPath:self.currentCellIndex atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

 

Cell 高度自适应 SDAutoLayout-Cell

Cell 高度自适应 SDAutoLayout-Cell

SDAutoLayout 只需要 3 步设置就可以实现 cell 和 tableview 高度自适应。

用到的库:

https://github.com/gsdios/SDAutoLayout

视频教程:

http://www.letv.com/ptv/vplay/24038772.html


Cell.add“ Cell Content”在Itext7版本7.1.12中不起作用是我还是Itext7提供的?这是一些代码

Cell.add“ Cell Content”在Itext7版本7.1.12中不起作用是我还是Itext7提供的?这是一些代码

如何解决Cell.add“ Cell Content”在Itext7版本7.1.12中不起作用是我还是Itext7提供的?这是一些代码

Cell SubTitle = new Cell().setBold();
Cell CA1Title = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell CA2Title = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell ExamTitle = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell TotalTitle = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell RemarkTitle = new Cell().setBold();
SubTitle.add("Subject");
CA1Title.add("1st C.A");
CA2Title.add("2nd C.A");
ExamTitle.add("Exam");
TotalTitle.add("Total score");
RemarkTitle.add("Remark");

方法Cell.add()不接受参数(String)。

出什么问题了?

解决方法

在iText中,并非所有元素都只能接受“简单”文本-一些元素是其他“ Block”元素的容器,而Text是Leaf元素。实际文本由TextParagraph类型的对象表示:

Text text1 = new Text("Text 1");
Paragraph p1 = new Paragraph(text1);
Paragraph p2 = new Paragraph("Text 2");

Cell本身(如其documentation所说)只是一个容纳其他元素的容器(并为Tables提供了col / row跨度)。因此,要向其中添加文本,您需要为其提供一个Paragraph元素以保持:

Cell myCell = new Cell()
    .add(new Paragraph("My Cell Title"))
    .setBold()
    .setTextAlignment(TextAlignment.CENTER);

Excel添加多个单元格的注释报错:Multiple cell comments in one cell are not allowed, cell: A1

Excel添加多个单元格的注释报错:Multiple cell comments in one cell are not allowed, cell: A1

Excel添加多个单元格的注释报错:Multiple cell comments in one cell are not allowed, cell: A1。

解决办法:

    anchor.setRow1(0); 
    anchor.setCol1(0); 
    Comment comment1 = drawing.createCellComment(anchor); 
    RichTextString richTextString1 = helper.createRichTextString("comment1"); 
    comment1.setString(richTextString1); 
    cell1.setCellComment(comment1); 

    anchor.setRow1(0); 
    anchor.setCol1(1); 
    Comment comment2 = drawing.createCellComment(anchor); 
    RichTextString richTextString2 = helper.createRichTextString("comment2"); 
    comment2.setString(richTextString2); 
    cell2.setCellComment(comment2); 

    anchor.setRow1(0); 
    anchor.setCol1(2); 
    Comment comment3 = drawing.createCellComment(anchor); 
    RichTextString richTextString3 = helper.createRichTextString("comment3"); 
    comment3.setString(richTextString3); 
    cell3.setCellComment(comment3); 

iOS - 关于 Cell 上 Button 点击效果 Cell添加Button点击无效果处理

iOS - 关于 Cell 上 Button 点击效果 Cell添加Button点击无效果处理

https://juejin.im/entry/580f4f33570c350068fea175

在iOS开发中,一直都有这样一个问题,就是在cell上添加一个button,当我们点击button时,它是没有高亮效果的,除非我们长按button,我这里整理一下解决这个问题的方法
原文链接: http://stackoverflow.com/questions/19256996/uibutton-not-showing-highlight-on-tap-in-ios7
解决方案一:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Button点击效果测试";

    self.tableView.delaysContentTouches = NO;

    // iOS7
    for (id view in self.tableView.subviews)
    {
        if ([NSStringFromClass([view class]) isEqualToString:@"UITableViewWrapperView"])
        {
            if([view isKindOfClass:[UIScrollView class]])
            {
                UIScrollView *scroll = (UIScrollView *) view;
                scroll.delaysContentTouches = NO;
            }
            break;
        }
    }

    // iOS8 注意,本人测试系统iOS10,没有走这个方法,走上面那个方法
    for (id view in self.tableView.subviews)
    {
        if ([NSStringFromClass([view class]) isEqualToString:@"UITableViewCellScrollView"])
        {
            if([view isKindOfClass:[UIScrollView class]])
            {
                UIScrollView *scroll = (UIScrollView *) view;
                scroll.delaysContentTouches = NO;
            }
            break;
        }
    }

    // 该方式相当于上面两个循环的合集,并且实现方式更加优雅,推荐使用它,而不是使用上面两个循环
    for (id obj in self.tableView.subviews) {
        if ([obj respondsToSelector:@selector(setDelaysContentTouches:)]) {
            [obj setDelaysContentTouches:NO];
        }
    }
}

解决方案二:

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesBegan:touches withEvent:event];
    [NSOperationQueue.mainQueue addOperationWithBlock:^{ self.highlighted = YES;}];
}

-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesCancelled:touches withEvent:event];
    [self performSelector:@selector(setDefault) withObject:nil afterDelay:0.1];
}

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesEnded:touches withEvent:event];
    [self performSelector:@selector(setDefault) withObject:nil afterDelay:0.1];
}

- (void)setDefault
{
    [NSOperationQueue.mainQueue addOperationWithBlock:^{ self.highlighted = NO; }];
}

该方案比较简单粗暴,我们创建一个UIButton的分类,然后将它导入pch文件中,就彻底解决了button的点击效果问题,比起方案一要简单一些

关于iOS 双击 TabBar 移动至未读消息 cell的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Cell 高度自适应 SDAutoLayout-Cell、Cell.add“ Cell Content”在Itext7版本7.1.12中不起作用是我还是Itext7提供的?这是一些代码、Excel添加多个单元格的注释报错:Multiple cell comments in one cell are not allowed, cell: A1、iOS - 关于 Cell 上 Button 点击效果 Cell添加Button点击无效果处理等相关知识的信息别忘了在本站进行查找喔。

本文标签: