目前正在为我的 iPhone 应用程序(如 Pocket,用户在第一次启动后进行一些动手操作)制作两个介绍页面(第一个显示图像,第二个应该显示一个网站)。遇到了 Matthew York 的项目,该项目与和GitHub
完美配合。此外,我喜欢在介绍中展示一个网站,但我无法让它发挥作用。我创建的只是没有出现。images
text
programmatically
UIWebView
Matthew York 的GitHub
项目:
https ://github.com/MatthewYork/iPhone-IntroductionTutorial
显示两个介绍页面的完整代码如下所示。请注意,它panelImage
按预期工作,但不是panelView
。我看到第二页出现了,但没有UIWebView
. 我想我将它添加subview
到view
屏幕上不可见的部分,因此我看不到它。我对吗?你能看看:[view addSubview:aWebView];
在method
:showWebView
视图控制器.m
- (void)showIntro
{
MYIntroductionPanel *panelImage = [[MYIntroductionPanel alloc] initWithimage:[UIImage imageNamed:@"img.jpg"] description:@"TEST: IMAGE"];
MYIntroductionPanel *panelView = [[MYIntroductionPanel alloc] initWitView:[self showWebView] description:@"TEST: VIEW"];
MYIntroductionView *introductionView = [[MYIntroductionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) headerText:@"TESTING" panels:@[panelImage, panelView] languageDirection:MYLanguageDirectionLeftToRight];
introductionView.BackgroundImageView.image = [UIImage imageNamed:@"BG_iPad_1024.png"];
introductionView.delegate = self;
[introductionView showInView:self.view];
}
- (UIView *)showWebView
{
UIWebView *aWebView= [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 290)];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
[aWebView loadRequest:requestObj];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
[view addSubview:aWebView];
return view;
}
MYIntroductionPanel.m
-(id)initWitView:(UIView *)view description:(NSString *)description{
if (self = [super init]) {
self.view = [[UIView alloc] init];
self.Description = [[NSString alloc] initWithString:description];
}
return self;
}
-(id)initWithimage:(UIImage *)image title:(NSString *)title description:(NSString *)description{
if (self = [super init]) {
self.Image = [[UIImage alloc] init];
self.Image = image;
self.Title = title;
self.Description = [[NSString alloc] initWithString:description];
}
return self;
}