gpt4 book ai didi

iphone - 在顶部显示 navigationController

转载 作者:行者123 更新时间:2023-11-29 13:23:28 26 4
gpt4 key购买 nike

我在我的应用程序中设置了一个 subview “弹出窗口”,如果用户点击 subview 弹出窗口上的按钮,我想显示一个 navController。到目前为止,我已经设置了按钮,但是如果我点击按钮,navigationController 会出现在我的弹出窗口下方!?我已经搜索了一些解决方案,但没有找到任何解决方案。整个 Controller 实际上显示在一个文件夹中,您可以在此处找到:https://github.com/jwilling/JWFolders所以viewDidLoad属于文件夹和rootview。我试图将其作为弹出窗口的 subview ,但这也不起作用。有谁知道如何治疗?我也以编程方式设置了弹出窗口和导航 Controller 。提前致谢。

我的代码:

导航 Controller 设置:

    - (IBAction)dothis:(id)sender {

MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];

// Set browser options.
browser.wantsFullScreenLayout = YES;
browser.displayActionButton = YES;


UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:browser];

[self presentModalViewController:navController animated:YES];

NSMutableArray *photos = [[NSMutableArray alloc] init];
MWPhoto *photo;
photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"star" ofType:@"png"]];
photo.caption = @"The star is soo beateful...";
[photos addObject:photo];

self.photos = photos;

}


- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
if (index < _photos.count)
return [_photos objectAtIndex:index];
return nil;
}
- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
return _photos.count;
}

弹窗代码:

   -(IBAction)mehr:(id)sender {
//the popup size and content
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 440)];
CGRect welcomeLabelRect = contentView.bounds;
welcomeLabelRect.origin.y = 20;
welcomeLabelRect.size.height = 40;
UILabel *welcomeLabel = [[UILabel alloc] initWithFrame:welcomeLabelRect];

//an simple activityindicator

activityindi = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityindi.frame = CGRectMake(120, 200, 40, 40);
[activityindi startAnimating];
[contentView addSubview:activityindi];

//The Imageview
CGRect infoimagerect = CGRectMake(5, 70, 270, 200);

UIImageView *infoimage = [[UIImageView alloc] initWithFrame:infoimagerect];

//and the Button

cubut = [UIButton buttonWithType:UIButtonTypeCustom];
[cubut addTarget:self
action:@selector(dothis:)
forControlEvents:UIControlEventTouchUpInside];
[cubut setTitle:nil forState:UIControlStateNormal];
cubut.frame = CGRectMake(5, 70, 270, 200);

//retrieving data from parse.com
PFQuery *query = [PFQuery queryWithClassName:@"My-Application"];
[query getObjectInBackgroundWithId:@"My-ID"
block:^(PFObject *textdu, NSError *error) {
if (!error) {

//hide the Button if there is no image
cubut.hidden=YES;

//the headline of popup
UIFont *welcomeLabelFont = [UIFont fontWithName:@"copperplate" size:20];

welcomeLabel.text = [textdu objectForKey:@"header"];
welcomeLabel.font = welcomeLabelFont;
welcomeLabel.textColor = [UIColor whiteColor];
welcomeLabel.textAlignment = NSTextAlignmentCenter;
welcomeLabel.backgroundColor = [UIColor clearColor];
welcomeLabel.shadowColor = [UIColor blackColor];
welcomeLabel.shadowOffset = CGSizeMake(0, 1);
welcomeLabel.lineBreakMode = UILineBreakModeWordWrap;
welcomeLabel.numberOfLines = 2;
[contentView addSubview:welcomeLabel];

//the image from parse

if (!error) {
PFFile *imageFile = [textdu objectForKey:@"image"];
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
UIImage *image = [UIImage imageWithData:data];
infoimage.image = image;
infoimage.contentMode = UIViewContentModeScaleAspectFit;
//show the button when the image appears
cubut.hidden = NO;




[contentView addSubview:infoimage];
//stop the activityindicator
[activityindi stopAnimating];

}
}];
}
} else {
//show some text
welcomeLabel.text = @"No connection!";
[welcomeLabel sizeToFit];
//hide the button
cubut.hidden = YES;

[contentView addSubview:infoLabel];
//stop the activityindicator
[activityindi stopAnimating];
}

}];
//add the content to the KNGModal view



[[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES];
}

我的viewDidLoad

- (void)viewDidLoad
{

but.hidden = YES;
PFQuery *query = [PFQuery queryWithClassName:@"myapp"];
[query getObjectInBackgroundWithId:@"Rgq5vankdf"
block:^(PFObject *textu, NSError *error) {
if (!error) {
but.hidden = NO;
but.color = [UIColor colorWithRed:0.90f green:0.90f blue:0.90f alpha:1.00f];

} else {

//if failure
but.hidden = YES;
mol.text = @"No Connection";

}

}];


[super viewDidLoad];

}

图片:

打开文件夹的按钮: enter image description here

文件夹本身: enter image description here

弹出窗口: enter image description here

提前致谢。

最佳答案

从目前的讨论和调试代码来看,您希望在带有导航 Controller 的弹出窗口中显示照片浏览器。

所以这里是 sample code它实现了这个功能,看看它。

我使用了相同的 KGModal 示例代码并根据要求进行了扩展。我已经使用 Xib 来查看带有导航栏的 View 。

要从应用程序中的任何位置关闭弹出窗口,您可以使用以下行,因为它是共享实例。

[[KGModal sharedInstance] hideAnimated:YES];

更新:

在 folderView 中显示照片浏览器的原因是,您试图在 folderView 中显示 photoBrowser,因此它在非常小的 folderView 中显示并且看不到任何照片。

所以我的建议是,当用户点击弹出窗口查看 photoBrowser 时,您只需删除弹出窗口并从 viewController 类中呈现 photoBrowser,因为除了此类之外,所有内容都通过 View 处理。

我已经按照上面的方法进行了修改并且工作正常,对于你给的代码,下载代码here看看它。

让我知道它是否满足您的需求。

谢谢

关于iphone - 在顶部显示 navigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13777395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com