簡體   English   中英

UIAlertView有3個文本字段和3個標簽相互重疊

[英]UIAlertView with 3 textfields and 3 labels overlap each other

我正在嘗試使用3個TextFields和3個Labels創建一個UIAlertView。

但是使用我當前的代碼,他們只是互相討論,我試圖改變AlertView的框架,我試圖使用CGAffineTransform,但他們都沒有工作。

這是我的代碼:

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Sign in" message:@"\n\n\n\n\n" delegate:self cancelButtonTitle:@"Stop" otherButtonTitles:@"Sign in",nil];

UILabel *customerIdLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 55, 65, 21)];

customerIdLabel.tag =1;
customerIdLabel.text = @"Customer id: ";
[myAlertView customerIdLabel];

UITextField *customerIdField = [[UITextField alloc] initWithFrame:CGRectMake(89, 50, 160, 30)];

customerIdField.tag = 2;
customerIdField.placeholder = @"Fill in your customer id";
[myAlertView customerIdField];

然后還有兩個組合。

這是我嘗試過的變換:

CGAffineTransform myTransform = CGAffineTransformMakeScale(1.0, 0.5f);
[myAlertView setTransform:myTransform];

這就是我得到的:

在此輸入圖像描述

我很確定你不應該像這樣使用UIAlertViews。 您應該設置標題,消息等,並使用[alertview show]。 文檔似乎很清楚,它是一個原樣的類.UIAlertViewStyle可能是你可以看到的東西,但選項是1個文本字段,1個安全字段,或用戶名和密碼字段。

您最好的選擇是使用新的UIViewController並使用presentViewController:animated:completion: call。

我通過不更改UIAlertView但在顯示時添加清晰視圖(可以使用空格填充)並在正確位置添加文本字段(注意旋轉發生時)來解決這個問題。 然后,讓水龍頭通過視圖到達UIAlertView。 這已經在商店的3個應用程序中通過Apple。

在xcode 5中的新SDK之前,您可以將子視圖添加到警報視圖,但不再起作用。 我不得不更新一個應用程序,因為這個討厭的代碼。 最好使用uipopovercontroller用於ipad或顯示UIView或甚至為ipad或iphone提供viewcontroller。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM