2
A
回答
7
我發現了一個解決方案: http://www.iphonedevsdk.com/forum/iphone-sdk-development/1704-uitextfield-inside-uialertview.html
這裏是爲我工作的代碼。
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[myAlertView setTransform:myTransform];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView addSubview:myTextField];
[myAlertView show];
[myAlertView release];
4
您需要創建彈出窗口(UIAlertView)並將UITextField(或任何您想使用的組件)添加到它作爲子視圖。 UIAlertView不會爲您添加的組件自動調整大小,因此您必須通過向其中添加文本來將它的那部分一起破解。該文本將增加彈出窗口的高度,並提供您不會添加太多被您的組件隱藏的內容。
1
將此函數添加到您的代碼中,在顯示警報之前調用它。
- (無效)willPresentAlertView:(UIAlertView中*)alertView { alertView.frame = CGRectMake(X,Y,寬度,heigth); }
1
一種調整您的UIAlertView中提示...
由於米倫Milkovski上/下,如果你設置了UIAlertView中的委託寫道:
UIAlertView* theAlert = [[UIAlertView alloc] initWithTitle:@"Lah"
message:@"dee dah"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
//NSLog(@"Pre Show: alert frame x,y: %f,%f, alert frame width,height: %f,%f", theAlert.frame.origin.x,theAlert.frame.origin.y, theAlert.frame.size.width, theAlert.frame.size.height);
[retrievingListAlert show];
然後,您可以修改通過定義以下UIAlertView回調(在委託類中 - 在這種情況下,因爲我們使用self,與創建UIAlertView的位置相同)的UIAlertView框架:
(void)willPresentAlertView:(UIAlertView *)alertView {
//NSLog(@"willPresentAlertView: alert frame midx,midy: %f,%f, alert frame width,height: %f,%f", alertView.frame.origin.x, alertView.frame.origin.y, alertView.frame.size.width, alertView.frame.size.height);
alertView.frame = CGRectMake(x, y, width, heigth);
}
我發現在其他時間設置幀不起作用。看起來show功能修改框架,大概是在自動調整內容的同時。
相關問題
- 1. 是否有任何全功能的Brainfuck編輯器可用?
- 2. 無編輯彈出VB編輯器
- 3. 彈出編輯模式中的多列
- 4. 是否有可能在jquery mobile中彈出(父)彈出窗口?
- 5. 是否有可能在沒有「編輯」菜單項的可可應用程序中具有「編輯」功能?
- 6. 是否支持摺疊F#編輯器中的所有功能節點?
- 7. Cocoa彈出式菜單中是否有層次可能?
- 8. RubyMine是否具有TextMate風格的多行編輯功能?
- 9. 如何在代碼編輯器中彈出jquery窗體編輯
- 10. 網格彈出編輯器中的可編輯網格
- 11. 是否有可能在Quartz.NET中編輯作業和觸發器
- 12. 編輯功能
- 13. 是否有可能編輯Eclipse命令
- 14. 從tinymce編輯器中刪除功能
- 15. Monobehaviour腳本中的編輯器功能
- 16. Bootstrap 3中有彈出功能嗎?
- 17. 使用彈出模式編輯
- 18. MVC 5編輯引導模式彈出
- 19. asp.net gridview編輯模式彈出日曆
- 20. 是否有Python內置Python編輯器?
- 21. Dojo是否有Markdown編輯器
- 22. 是否有eot字體編輯器?
- 23. 是否有任何.editorconfig GUI編輯器?
- 24. 如何在Sitecore頁面編輯器中啓用編輯功能?
- 25. Richfaces 4彈出編輯器困境
- 26. Designer彈出窗口編輯器問題
- 27. iPhone:是否有可能以編程方式製作視頻
- 28. 是否有可能以編程方式將iPhone靜音?
- 29. 是否有jQuery退出功能?
- 30. Javascript彈出功能