我有一个方法,我从我的主视图调用,即设置我想要显示在滚动视图中的图像的图像名称。如何重新加载当前UIView
- (void)loadImage:(NSString *)myImageName
{
if (myImageName == @"one") {
imageName = myImageName;
}
if (myImageName == @"two") {
imageName = myImageName;
}
if (myImageName == @"three") {
imageName = myImageName;
}
//Reloads view here???
}
我加载在我viewDidLoad方法的相似图片时,我设置为从parentview的imagename从tableviewcell选择我NSString的向下传递到的LoadImage所以
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Create scrollview
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
scrollView.delegate = self;
scrollView.bounces = NO;
//Create scrollviewimage
if (imageName == @"one") {
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ha.png"]];
}
if (imageName == @"two") {
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"haha.png"]];
}
if (imageName == @"three") {
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hahaha.png"]];
}
containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 550)];
//Add subview
[containerView addSubview:image];
//initViews
scrollView.contentSize = containerView.frame.size;
[scrollView addSubview:containerView];
//scrolling
scrollView.minimumZoomScale = 1.0;
scrollView.maximumZoomScale = 31.0;
[scrollView setZoomScale:scrollView.minimumZoomScale];
//highrachy
[self.view addSubview:scrollView];
}
会发生什么事..然后载荷图像设置viewdidload中的名称..但是,发生的事情是,只有第一个选择剂量任何东西..所以你总是会看到你选择的第一个图像..所以,如果你选择图像两个你选择的每个其他图像将显示图像二..
an Ÿ帮助会很好。
这里是parentview小区选择是什么样子
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Sets the back button for the new view that loads (this overrides the usual parentview name with "Back")
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:nil action:nil];
if (!self.detailViewController) {
self.detailViewController = [[ICDDetailViewController alloc] initWithNibName:@"ICDDetailViewController" bundle:nil];
if (indexPath.section == 0) {
_detailViewController.imageName = @"one";
// NSLog(@"%@", indexPath);
}
if (indexPath.section == 1) {
_detailViewController.imageName = @"two";
// NSLog(@"%@", indexPath);
}
if (indexPath.section == 2) {
_detailViewController.imageName = @"three";
// NSLog(@"%@", indexPath);
}
}
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
opps现在这样做。 – 2012-01-31 22:19:29
它工作?为了更加清晰,我更新了答案。 – Justin 2012-01-31 22:57:57