gpt4 book ai didi

ios - 在 "fullscreen" View 中显示图像 - 当 ImageView 被点击时

转载 作者:行者123 更新时间:2023-11-28 20:02:33 25 4
gpt4 key购买 nike

a simple test app for iPhone我在顶部显示(使用 SDWebImage)用户头像:

app screenshot

当应用用户点击头像时,我想在另一个 View 中“全屏”显示该图片。

所以我将该 View 添加到我的 Xcode 5 Storyboard中,还添加了点击识别器和我称之为“pushZoom”的推送转场(此处为 fullscreen):

Xcode screenshot

点击识别器工作正常,我可以看到它的方法被调用。

我的问题: 在 Interface Builder 中是否有一种简单的方法可以将图像传递到新 View ,或者我是否必须采用乏味的方式(添加 ZoomViewContoller.[mh] 文件,定义一个 ImageView 的导出)?

下面是我的 ViewController.m 的副本以防我稍后修改@GitHub:

#import "ViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>

static NSString* const kAppleMaps = @"https://maps.apple.com/?q=%@";
static NSString* const kGoogleMaps = @"comgooglemaps-x-callback://?q=%@&x-success=myphone://?resume=true&x-source=MyPhone";
static NSString* const kAvatar = @"https://lh6.googleusercontent.com/-6Uce9r3S9D8/AAAAAAAAAAI/AAAAAAAAC5I/ZZo0yzCajig/photo.jpg";

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];

[self setTitle:@"Google+"];

_firstName.text = @"Alex";

[_cityBtn setTitle:@"Bochum" forState:UIControlStateNormal];

[_imageView setImageWithURL:[NSURL URLWithString:kAvatar]
placeholderImage:[UIImage imageNamed:@"Male.png"]];
}

- (IBAction)avatarTapped:(id)sender {
NSLog(@"%s", __PRETTY_FUNCTION__);
}

- (IBAction)cityPressed:(id)sender
{
NSURL* testURL = [NSURL URLWithString:@"comgooglemaps-x-callback://"];
NSString* fmt = ([[UIApplication sharedApplication] canOpenURL:testURL] ? kGoogleMaps : kAppleMaps);
NSString* city = [self urlencode:_cityBtn.currentTitle];
NSString* str = [NSString stringWithFormat:fmt, city];
NSLog(@"%s: city=%@ str=%@", __PRETTY_FUNCTION__, city, str);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}

- (NSString*)urlencode:(NSString*)str
{
return (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef) str,
NULL,
CFSTR(":/?@!$&'()*+,;="),
kCFStringEncodingUTF8));
}

@end

最佳答案

为什么需要另一个 viewController。您可以在最初没有任何图像的情况下在您的 View 上保留全尺寸的 imageView 并将其隐藏,然后点击该按钮,将其从隐藏中移除。并传递图像。所以它不需要任何这些问题。对我来说似乎很简单

关于ios - 在 "fullscreen" View 中显示图像 - 当 ImageView 被点击时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23341534/

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