文字段的總體複製

2022-07-27 17:48:10 字數 1324 閱讀 4560

在做專案的時候常常遇到一些地方須要複製文字框的內容,儘管簡單但還是稍做總結。

對複製的操作通常是在標籤欄上(label)。響應通常是長按手勢(longpressgesture),其它情況不做贅述。

首先宣告乙個方法:

- (void)copyactionwithview:(uiview *)view withstring:(nsstring *)text withsuperview:(uiview *)superview;
在標籤欄上加入手勢,設定可觸控屬性:

_contentlabel.userinteractionenabled = yes;

uilongpressgesturerecognizer * longpressgr = [[uilongpressgesturerecognizer alloc] initwithtarget:self action:@selector(longpress:)];

[_contentlabel addgesturerecognizer:longpressgr];

- (void)longpress:(uilongpressgesturerecognizer *)sender

}

實現:(一般在控制器上)

- (void)copyactionwithview:(uiview *)view withstring:(nsstring *)text withsuperview:(uiview *)superviewelse

targetrect.origin.x = 110;

targetrect.size.width = 100;

targetrect.size.height = 17.1;

[menu settargetrect:targetrect inview:self.view];

[menu setmenuvisible:yes animated:yes];

}- (bool)canperformaction:(sel)action withsender:(id)sender

return no;//不顯示

}- (bool)canbecomefirstresponder

- (void)copyaction:(id)sender

在通常情況下,須要複製的文字都是在較深層次的檢視,一般要通過協議實現詳細的方法。這裡僅僅是簡要說明。

另外還能夠自己定義彈出點(複製小窗體)的位置。

上傳乙個演示樣例。展示一下效果:

文字段的整體複製

在做專案的時候經常遇到一些地方需要複製文字框的內容,雖然簡單但還是稍做總結。對複製的操作一般是在標籤欄上 label 響應一般是長按手勢 longpressgesture 其他情況不做贅述。首先宣告乙個方法 void copyactionwithview uiview view withstring...

http報文字段

一 response header 1.access control allow credentials or 下面這點要注意 2.access control allow credentials 取值只有true 沒有false 不需要就省略此欄位 二 cors 跨域資源共享 cross orig...

提取中文字段的 縮寫

create function fn getpy str nvarchar 4000 returns nvarchar 4000 with encryption 提取中文字段的 縮寫 每個字的首字母組合 as begin declare intlen int declare strret nvarc...