I have a UIViewController
that instantiates another UIViewController
(with NIB) and pushes it to the screen. I then try to set UILabel
and get UIWebView
to load URL. However it doesn't work! No errors! Interface looks just like in NIB and no programmatic measures to set UILabel
to a different @"TestString"
work.
Can someone point me to the issue? I just can't seem to resolve it.
Thank you.
Instantiated UIViewController - WebView.h:
#import <UIKit/UIKit.h>
@interface WebView : UIViewController {
}
@property (strong, nonatomic) IBOutlet UILabel *testLabel;
@property (strong, nonatomic) IBOutlet UIWebView *webView;
- (void) openWeb: (NSString *) url;
@end
Instantiated UIViewController - WebView.m:
#import "WebView.h"
@interface WebView ()
@end
@implementation WebView
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
_testLabel = [[UILabel alloc] init];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void) setTestLabel:(UILabel *)theTestLabel {
NSLog(@"Called set Label: %@", [theTestLabel text]);
_testLabel = theTestLabel;
}
- (void) openWeb: (NSString *) url {
NSLog(@"openWeb with url %@", url);
[_testLabel setText:url];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[[NSURL alloc] initWithString:url]];
[_webView loadRequest:urlRequest];
}
@end
Instantiating Part:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ScheduledClass *c = [classes objectAtIndex:[indexPath row]];
WebView *webView;
webView = [[WebView alloc] initWithNibName:@"WebView" bundle:nil];
UILabel *label = [[UILabel alloc] init];
label.text = @"Testing";
[webView setTestLabel:label];
[webView openWeb:@"http://meirz.net"];
[self.navigationController pushViewController:webView animated:YES];
}
Update: Confirmed connections