login Line Notify
URL:https://notify-bot.line.me/zh_TW/
選「個人頁面」
login Line Notify
URL:https://notify-bot.line.me/zh_TW/
選「個人頁面」
環境 XCODE 12.4, IOS14.4
1.參考「https://stackoverflow.com/questions/16868117/uitextview-that-expands-to-text-using-auto-layout」,製作grewing text view 的xib.
(我是直接用xcode interface builder的 Hight Priority & content Hugging Priority那段去做的,畢竟我連swift都還不會)
2.參考「www.dotnetmobile.com/XamariniOS/CreatingCustomView」及「https://docs.microsoft.com/zh-tw/xamarin/ios/user-interface/storyboards/」把這個xib跟c#做連結,
參考結果
ViewGrowingText.cs ViewGrowingText.designer.cs ViewGrowingText.xib
如果你直接把它加入UIViewController去試跑,應該是有這效果.
---sample code----
var TxtTest = UI.ViewGrowingText.Create();
TxtTest.Frame = new CoreGraphics.CGRect(0, 200, View.Frame.Width, 30);
//viewMain是我們在xcode中用outlet指定最底層的view為此UIViewcontroller中的變數成員,基本上跟「View」這個在UIViewController中的變數是同一個東西
viewMain.AddSubview(TxtTest);
viewMain.LayoutIfNeeded();
----------------
-----實驗完記得把這個TxtTest移掉,因為這不是我們要的結果-----
現在,我們在目前的UIViewController底部加一個TextView(或是TextField沒差)名字為「txtMsg2Send」
我們要把個GrowingTextView放到小鍵盤上面,而且要能自已依照灰色TextView加減的高度而自己跟著調整高度,要在操作txtMsg2Send會出現
直接看code吧
------------------------------------------------
nfloat orgHeightOfTxtViewOfInputAccessoryView = 0;
UI.ViewGrowingText inputAccessoryView =null;
UITextView txtViewOfInputAccessoryView =null;
public override void ViewDidLoad() {
base.ViewDidLoad();
if (inputAccessoryView == null) {
inputAccessoryView = UI.ViewGrowingText.Create();
txtViewOfInputAccessoryView = inputAccessoryView.GetTextView();
inputAccessoryView.Frame =
new CoreGraphics.CGRect(0, 0, View.Frame.Width, txtViewOfInputAccessoryView.Frame.Height);
inputAccessoryView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;
//把這個會長高長壯的GrowingTextView設定為底部的textView的鍵盤工具列
txtMsg2Send.InputAccessoryView = inputAccessoryView;
//先把最初的高度記下來.....
orgHeightOfTxtViewOfInputAccessoryView = txtViewOfInputAccessoryView.Frame.Height;
//重點來了!!文字變時.如何改變inputAccessoryView的高度!?
txtViewOfInputAccessoryView.Changed += (object sender, EventArgs e) => {
var _t = new System.Threading.Thread(new System.Threading.ThreadStart(() => {
InvokeOnMainThread(async () => {
await Task.Delay(50);
//只比較textView高度到小數點三位數
if (Math.Round(txtViewOfInputAccessoryView.Frame.Size.Height, 3, MidpointRounding.AwayFromZero) !=
Math.Round(orgHeightOfTxtViewOfInputAccessoryView, 3, MidpointRounding.AwayFromZero)) {
//高度異動!!調整外層inputAccessoryView的高度
//光是用Frame=....是沒用的,要動到cosntraints裡才會作動!!
orgHeightOfTxtViewOfInputAccessoryView = (float)txtViewOfInputAccessoryView.Frame.Size.Height;
var cst =
inputAccessoryView.Superview.Constraints.Where(Q => Q.Identifier() == "accessoryHeight").FirstOrDefault();
cst.Active = false;
inputAccessoryView.LayoutIfNeeded();
cst.Constant = orgHeightOfTxtViewOfInputAccessoryView;
cst.Active = true;
inputAccessoryView.Superview.AddConstraint(cst);
if (inputAccessoryView.Superview.Superview != null) {
inputAccessoryView.Superview.Superview.LayoutIfNeeded();
}
}
});
}));
_t.Start();
...
...end of ViewDidLoad.....
}
-------------------------------------------------
結果....
是不是愈來愈有專業的樣子了呢?
OS:自從我用了GrowingTextView之後,考試都考一百分,而且人明顯高了、壯了、變得更美了,
上述那段紅字,請參考這裡 我只是把它改成xamarin c# 罷了,懂得真的太少了,真的要花點時間學swift了
另一種作法是在出現小鍵盤時,整個畫面往上捲,配合在UIViewController底部的GrowingText來做到這效果,請參這裡 的keyboard事件處理
哪個好!? 鐘鼎山林,人各有志,攏好啦
大家加油吧
(反正疫情期間哪都不能去,乖乖在家好好寫程式吧)
現在xamarin.ios的xib都只能在xcode之下設計了,著實非常不便
但沒辦法,實在不想用xamarin form 架構,只好認命了
UILabel雖然在xcode interfacebuilder中有「UserInteractionEnabled」設定可以讓你勾,
但,經過實驗,真的,你還是要在code中設定才能listen tap 事件,參考以下
------------------------------------
var tapRecognizer = new UITapGestureRecognizer();
tapRecognizer.AddTarget(() => {
// tap時事件實作
...
...
...
});
lblA.UserInteractionEnabled = true;
tapRecognizer.NumberOfTapsRequired = 1;
lblA.AddGestureRecognizer(tapRecognizer);
-------------------------------------
我書讀不多,不知道原來addTarget是要這樣用(而不是action !?)
anyway,總之,要用AddTarget設定實作,UserInteractionEnabled要設定(雖然我已經在xcode設計階段就指定了,真的,還是要在code設定才行),NumberOfTapsRequired 也要指定,最後加入GestureRecognizer
參考:這裡
一起加油吧.
雖然有過場動畫會比較花俏可愛,但正式/商用app是不喜歡這種玩意兒的
如何取消過場動畫?
兩個指令就可以了
----在某個ativity裡要切換到下個actity的片段----------
Intent itxnNext=
new Intent(this, typeof(下個actity類別的class路徑)).AddFlags(ActivityFlags.NoAnimation);
StartActivity(itxnNext);
OverridePendingTransition(0, 0);
Finish();
-----------------------------------------------
注意!!
OverridePenddingTransition指令一要在StartActivity指令之後,順序一定要對!!
不然你會試不出效果的!!
參考:這裡
一起加油吧
安安,給虧嗎? (會用「安安」的表示這一定是個老網民了)
安安不給虧不要緊,程式不給debug才麻煩吧
今天就是要講這樣一個故事--一個asp.net core web project從他台搬來新的PC
卻一直debug不行,直接結束,clear & rebuild也一樣,明明build都成功啊.....
就某32bit data而言 (ex : *pRccCfg)
經初始化0b0
我們把bit 22設定為1 之後 (by instruction : 「 *pRccCfg|= (1<<22) ; 」)
要把bit 24~26設定為0b110,又不能動到之前設定的其他bit值,如何是好?
作法1.一個bit一個bit設定
*pRccCfg!=(1<<25)
*pRccCfg!=(1<<26)
作法二,用罩除的方式,比較不建議請注意"~"的用法
*pRccCfg!=(7<<24); // "OR" the 3 bits by 0b111
*pRccCfg &=~(1<<24);//shift the bit ,then "Complement them",then,use "AND" opeartion,
------------------------------------------------------------------------
同理,只是想清除某幾個bit,也是先 shift "on" bits ,"Complement them",then ,use "AND"operation
ex:要把21&22 bits清除,但不要動到其他bits,請用以下方式
*pAddrRccCfg &=~(0x3<<21);
務必注意!!
~(0x3<<21) 是
11111111100111111111111111111111
而(~0x3<<21) 是
11111111100000000000000000000000
千萬要注意順序
2.Install WinHttpHandler:
Install-Package System.Net.Http.WinHttpHandler
3.Extend WinHttpHandler to add http2.0 support:
public class Http2CustomHandler : WinHttpHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
request.Version = new Version("2.0");
return base.SendAsync(request, cancellationToken);
}
}
4.Pass above handler to the HttpClient constructor
using (var httpClient = new HttpClient(new Http2CustomHandler()))
{
// your custom code
}
---------------------------------(所以就是要用非同步的方式去呼叫了,沒差,用執行緒去做就是了)雖然案主說你就再申請一個apns 憑證嘛.何必這樣大費周章?
可是每一個憑證每年都要換證,就是怕在換證時uer漏接了重要的訊息
這次一做,日後很多個APP都可以共用,也沒有期限問題,長痛不如短痛啊,根本性地解決問題,不亦快哉?
在xamarin ios經常更新,以往的加解密函數現在出現這現象
----code----
var s = new SecRecord(SecKind.GenericPassword) {
ValueData = NSData.FromString(value),
Generic = NSData.FromString(key),
Invisible = true,
CreationDate = NSDate.Now
};
var err = SecKeyChain.Add(s);
------------------
結果err傳回值是「Security.SecStatusCode.MissingEntitlement」
好在別人已經踢到鐵板了,請參考以下的方式修改
https://forums.xamarin.com/discussion/145357/seckeychain-add-return-security-secstatuscode-missingentitlement
注意,其中的
------------
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)你的appBundle ID</string>
</array>
------------------------------------
紅色字$(AppIdentifierPrefix)要去掉,
這是用vs2019 IOS manifest Editor打開加入keychain選項他自己加上去的
要小心--盡信editor不如無editor
加油!!
安卓開發就怕一直在改版的問題一再發生
最近很多開發者都遇到明明在notification的震動機制好好的,怎麼升級後又惦惦了
google了一下是要加上 audioattribute--
---example-----
audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_ALARM) //key
.build();
mVibrator.vibrate(pattern, 1, audioAttributes);-----------------來源參考:https://www.jianshu.com/p/3ec9158b2041同場加映有些圓標可以用線上的icon generator來產生
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
請多加利用左側功能表中的background color等屬性
https://romannurik.github.io/AndroidAssetStudio/index.html <--這裡還有 notification icon generator可以用哦
(一升級就搞得大家雞飛狗跳的,希望馬斯克的手機系統不會這樣麻煩)
大家加油吧