添加一些控件UIAlertView
已在iOS7中使用addSubview
方法弃用.据我所知,Apple承诺增加contentView
财产.
iOS 7现已发布,我发现此属性未添加.这就是为什么我搜索一些能够为此alertView添加进度条的自定义解决方案.例如类似于TSAlertView的东西,但更适合在iOS 7中使用.
下面的代码适用于iOS6(以及之前的版本),但UITextField不会在iOS7中显示...有关如何在iOS7中的UIAlterView中显示UITextField的任何想法?
UIAlertView* dialog = [[UIAlertView alloc] init];
[dialog setDelegate:self];
[dialog setTitle:@"Enter ESC Score"];
[dialog setMessage:@" "];
[dialog addButtonWithTitle:@"Cancel"];
[dialog addButtonWithTitle:@"OK"];
dialog.tag = 5;
nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setKeyboardType:UIKeyboardTypeNumberPad];
[nameField becomeFirstResponder];
[nameField setBackgroundColor:[UIColor whiteColor]];
[dialog addSubview:nameField];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, 0.0);
[dialog setTransform: moveUp];
[dialog show];
[dialog release];
[nameField release];
Run Code Online (Sandbox Code Playgroud)
iOS6的代码运行显示:
iOS7中的相同代码显示此内容(请注意UITextField如何丢失且没有键盘):
objective-c uitextfield uialertview ios7 uialertviewdelegate
我想创建一个UIAlertView,它会说"......正在进行中".它还将显示UIActivityindicatorView就可以了.你能让我知道我该怎么办?
谢谢.
以下代码在iOS 5到6.1中运行良好.我甚至在应用程序中存储了该代码:
-(void)showActivityIndicator
{
if(!mLoadingView) //
{
mLoadingView = [[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
mLoadingView.tag = kAlertViewTag;
}
[mLoadingView show];
}
- (void)willPresentAlertView:(UIAlertView *)alertView
{
if (alertView.tag == kAlertViewTag)
{
UIActivityIndicatorView *actInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
actInd.frame = CGRectMake(128.0f, 45.0f, 25.0f, 25.0f);
[alertView addSubview:actInd];
[actInd startAnimating];
UILabel *l = [[UILabel alloc]init];
l.text = NSLocalizedString(@"PRODUCT_PURCHASE_INDICATOR_TITLE", @"Please wait...");
l.font = [UIFont fontWithName:@"Helvetica" size:16];
float strWidth = [l.text sizeWithFont:l.font].width;
float frameWidth = alertView.frame.size.width;
l.frame = CGRectMake((frameWidth - strWidth)/2, -25, 210, 100); …
Run Code Online (Sandbox Code Playgroud) 我想用两个按钮创建UIAlertView.我需要垂直布置这些按钮(我的文字太大了).可能吗 ?
屏蔽1
画面2