本文介绍了自定义UI:iOS Objective-C中的弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个自定义弹出窗口,并且想动态生成代码而不使用UI拖放.
I want to create a custom popup and I want to generate a code dynamically without using UI drag and drop.
视图应如下所示:
我正在使用以下代码调用弹出窗口:
I am using the following code to call the popup :
CustomPopUp *cp = [[CustomPopUp alloc]init];
cp.view.frame = CGRectMake(0.0, 0.0, 300, 300);
KLCPopup* popup = [KLCPopup popupWithContentView:cp.view];
[popup show];
自定义弹出代码如下:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.gaScreenName = @"Login";
if (firstPageLoad) {
return;
}
LinearLayoutPageHeading *heading = [[LinearLayoutPageHeading alloc] initWithText:@"Sign in." maxWidth:[LayoutValues getMaxWidthClipped]];
[self.topContainerContent addObject:heading];
NSString *content = @"New patient? Register here.";
LinearLayoutLinksViewItem *contentItem = [[LinearLayoutLinksViewItem alloc] initLinksViewWithText:content font:[PPFonts genericParagraphFont] maxWidth:[LayoutValues getMaxWidthClipped] links:nil];
[self.topContainerContent addObject:contentItem];
LinearLayoutTextInputAndLabel *emailField = [[LinearLayoutTextInputAndLabel alloc] initWithLabelText:@"EMAIL ADDRESS" maxWidth:[LayoutValues getMaxWidthClipped]];
emailField.textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
LinearLayoutButton *continueButton = [[LinearLayoutButton alloc] initWithText:@"SIGN IN" maxWidth:[LayoutValues getMaxWidthClipped] url:nil type:@"primary"];
[self.topContainerContent addObject:continueButton];
LinearLayoutLinksViewItem *noticesPar = [[LinearLayoutLinksViewItem alloc] initLinksViewWithText:@"By clicking Sign In you agree to our Consent to Telehealth, Consent to Request Medical Services, Privacy Policy and Terms of Use." font:[PPFonts signInTermsParagraph] maxWidth:[LayoutValues getMaxWidthClipped] links:nil];
noticesPar.padding = CSLinearLayoutMakePadding(0, noticesPar.padding.left, 10, noticesPar.padding.right);
[self.topContainerContent addObject:noticesPar];
[self renderPageContainers];
firstPageLoad = YES;
}
@end
我使用的是自定义创建的视图控制器,但弹出的窗口为空.
I am using custom created view controller but am getting a blank popup.
是否可以使用标准UIViewController
获取上述布局?我是iOS开发的新手,到目前为止还没有动态生成UI视图.
Is there a way to get the above layout using standard UIViewController
? I am new to iOS development and have not dynamically generated UI views so far.
推荐答案
以下是自定义弹出窗口的好示例. 自定义PopUP视图.只需在其中添加容器即可.
Here is the good example for custom popup. Custom PopUP View. Just add your container in it.
这篇关于自定义UI:iOS Objective-C中的弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!