如何对整个字进行grep(How to grep for the whole word)
我正在使用以下命令来grep在子目录中的东西
find . | xargs grep -s 's:text'
但是,这也会发现像
<s:textfield name="sdfsf"...../>
我可以做些什么来避免这种情况,因为它只是找到像
<s:text name="sdfsdf"/>
或者这个问题....还发现
<s:text somethingElse="lkjkj" name="lkkj"
基本上
s:text
和name
应该在同一行....I am using the following command to grep stuff in subdirs
find . | xargs grep -s 's:text'
However, this also finds stuff like
<s:textfield name="sdfsf"...../>
What can I do to avoid that so it just finds stuff like
<s:text name="sdfsdf"/>
OR for that matter....also finds
<s:text somethingElse="lkjkj" name="lkkj"
basically
s:text
andname
should be on same line....
原文:https://stackoverflow.com/questions/2879085
最满意答案
你不能有单独的代表。
UICollectionView
是UIScrollView
的子类,并覆盖其delegate
属性以将其类型更改为UICollectionViewDelegate
(这是UIScrollViewDelegate
的子类型)。 因此,您只能将一个委托分配给集合视图,并且它可以实现UICollectionViewDelegate
方法和UIScrollViewDelegate
方法的任意组合。但是,您可以毫不费力地将
UIScrollViewDelegate
方法转发到另一个对象。 这是你在Swift中的表现; 它在Objective-C中非常相似(因为这都是使用Objective-C运行时完成的):import UIKit import ObjectiveC class ViewController: UICollectionViewController { let scrollViewDelegate = MyScrollViewDelegate() override func respondsToSelector(aSelector: Selector) -> Bool { if protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, false, true).types != nil || protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, true, true).types != nil { return scrollViewDelegate.respondsToSelector(aSelector) } else { return super.respondsToSelector(aSelector) } } override func forwardingTargetForSelector(aSelector: Selector) -> AnyObject? { if protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, false, true).types != nil || protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, true, true).types != nil { return scrollViewDelegate } else { return nil } }
请注意,
MyScrollViewDelegate
可能必须是NSObject
的子类才能使其正常工作。You cannot have separate delegates.
UICollectionView
is a subclass ofUIScrollView
, and overrides itsdelegate
property to change its type toUICollectionViewDelegate
(which is a subtype ofUIScrollViewDelegate
). So you can only assign one delegate to a collection view, and it may implement any combination ofUICollectionViewDelegate
methods andUIScrollViewDelegate
methods.However, you can forward the
UIScrollViewDelegate
methods to another object without much difficulty. Here's how you'd do it in Swift; it would be very similar in Objective-C (since this is all done using the Objective-C runtime):import UIKit import ObjectiveC class ViewController: UICollectionViewController { let scrollViewDelegate = MyScrollViewDelegate() override func respondsToSelector(aSelector: Selector) -> Bool { if protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, false, true).types != nil || protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, true, true).types != nil { return scrollViewDelegate.respondsToSelector(aSelector) } else { return super.respondsToSelector(aSelector) } } override func forwardingTargetForSelector(aSelector: Selector) -> AnyObject? { if protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, false, true).types != nil || protocol_getMethodDescription(UIScrollViewDelegate.self, aSelector, true, true).types != nil { return scrollViewDelegate } else { return nil } }
Note that
MyScrollViewDelegate
probably has to be a subclass ofNSObject
for this to work.
相关问答
更多-
好的,我会以完全不同的方式解决这个问题。 首先,完全摆脱scrollView。 只需在整个界面中使用UICollectionView即可。 UICollectionView可以为节标题使用UIView。 用你的UITextView制作这个UIView。 您需要手动计算UITextView(和UIView)的正确高度。 就像是... CGSize size = [theText sizeWithFont:
constrainedToSize:CGSizeMake(desiredW ... -
你不能有单独的代表。 UICollectionView是UIScrollView的子类,并覆盖其delegate属性以将其类型更改为UICollectionViewDelegate (这是UIScrollViewDelegate的子类型)。 因此,您只能将一个委托分配给集合视图,并且它可以实现UICollectionViewDelegate方法和UIScrollViewDelegate方法的任意组合。 但是,您可以毫不费力地将UIScrollViewDelegate方法转发到另一个对象。 这是你在Swift ...
-
重用collectionView(Reusing collectionView)[2021-05-28]
您应该将所有这些逻辑放入一个单独的VC并重用VC,您不仅仅是尝试重用集合视图。 因此,无论您何时需要此集合视图的“副本”,您实际上都会添加子VC并将VC中的视图添加为子视图。 You should put all of this logic into a separate VC and reuse the VC, you aren't just trying to reuse the collection view. So, wherever you need a 'copy' of this collec ... -
你有没有在scrollViewDidEndDecelarating之后尝试reloadData()? 我尝试提出另一种方法: override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { guard let cell = cell as? CollectionView ...
-
如何使滚动视图基于集合视图在ios中增加行数?(how to make scrollview grow based on collection view number of rows in ios?)[2023-12-14]
您可以增加CollectionView Height Constraint的高度,将Height包含到您的ViewController并比。 如何连接约束到插座? let height = self.collectionView.contentSize.height; self.heightConstraints = height; self.scrollView.contentSize = CGSize.init(widht:self.scrollView.frame.size.width,height ... -
这解决了。 问题在于我为两个UICollectionView使用了相同的UICollectionViewFlowLayout。 这导致了异常。 最后,我为两个控制器使用了不同的类,这解决了在委托方法中选择正确的CollectionView的问题。 非常感谢您的意见! This is solved. The problem was the fact that I used the same UICollectionViewFlowLayout for both UICollectionViews. This ...
-
使用一个collectionview IOS滚动多个UICollectionView(Scroll Multiple UICollectionView with one collectionview IOS)[2022-04-03]
好的我已经检查了我的代码,我的工作是:我在屏幕的左侧有一个tableView,其余的是UIScrollView,在其中我在顶部有一个宽度等于collectionView.contentSize的视图.width,并在该视图下方,collectionView,其高度等于屏幕高度,宽度等于其contentSize.width。 之后,ScrollView只能水平滚动,而collectionView只能垂直滚动,所以,当你水平滚动时,tableView会停留,标题视图和集合会水平滚动,如果你垂直滚动,标题视图会保 ... -
好。 你想要一个UICollectionView,但你也希望在同一个屏幕上有很多常规的“查看”项目? 有两件事很重要: 1.您不需要两个ViewControllers。 您只需要将通常作为常规ViewController的UICollectionViewController加载: @interface UserViewController : UIViewController
2.完成后,您可以在该视图的 ... -
scrollToItem水平滚动collectionView崩溃(scrollToItem horizontal scrolling collectionView crash)[2022-12-02]
在你的评论中你说过: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UICollectionView must be initialized with a non-nil layout parameter'. I believe there is something wrong in my func scrollToMenuIndex()... when I remove that func ... -
都不是。 创建自己的UIView子类,它有一个UIPanGestureRecognizer 。 识别平移时,更新子视图的位置。 添加和删除边缘的孩子,这样你就不会有太多的孩子。 (当视图移动到屏幕外时,您可以removeFromSuperview )。 Neither. Create your own UIView subclass which has a UIPanGestureRecognizer. When the pan is recognized, update the position of y ...