no visible #interface for declares the selector errors - objective-c

I'm getting No visible #interface for 'NSObject' declares the selector 'viewDidLoad' on
the lines:
[super viewDidLoad];
[_viewWeb loadRequest:requestObj];
[super didReceiveMemoryWarning];
UIViewControllerHUB.m
#import "UIViewControllerHUB.h"
#interface UIViewControllerHUB ()
#property (strong, nonatomic) NSMutableArray *subItems;
#end
#implementation UIViewControllerHUB
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *fullURL = #"http://conecode.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_viewWeb loadRequest:requestObj];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
UIViewControllerHUB.h
#import <Foundation/Foundation.h>
#interface UIViewControllerHUB : NSObject
#property (strong, nonatomic) IBOutlet UIView *viewWeb;
#end
How can I fix this?
EVERYTHING ABOVE IS NOW RESOLVED.
New error below:
Now getting 'No visible #interface for 'UIView' declares the selector 'loadRequest:'
on line
[_viewWeb loadRequest:requestObj];

In your code 'No visible #interface for UIView declares the selector 'loadRequest:' on line why you are getting this error is becuase loadRequest is not the method of UIView. But in-spite of that it is the method of UIWebView. For more refer this UIWebView documentation . So just replace UIView to UIWebView and check
//Comment this
//#property (strong, nonatomic) IBOutlet UIView *viewWeb;
//Modify this
#property (strong, nonatomic) IBOutlet UIWebView *viewWeb;
Note:- As you have created outlet of UIView. So delete the same and drag-drop UIWebView and then reconnect the outlet to UIWebView

viewDidLoad is a UIViewController method. To fix it, change to inherit from that:
#import <Foundation/Foundation.h>
#interface UIViewControllerHUB : UIViewController
#property (strong, nonatomic) IBOutlet UIView *viewWeb;
#end

Related

Not Properly Passing Data Between Views

I'm trying to send text generated by the user from the AuthenticationViewController to MainProfileViewController. I'm not receiving an error report. The label just doesn't even appear in the MainProfileViewController. The outlets are correctly hooked up. Thanks for the help!
#import <UIKit/UIKit.h>
#class MainProfileViewController;
#interface AuthenticationViewController : UIViewController
{
MainProfileViewController *mainProfileViewController;
}
#property (retain, nonatomic) IBOutlet UITextField *usernameTextField;
#end
#import "AuthenticationViewController.h"
#import "MainProfileViewController.h"
#interface AuthenticationViewController ()
#end
#implementation AuthenticationViewController
#synthesize usernameTextField;
- (IBAction)createAccount: (id)sender {
{
mainProfileViewController = [[MainProfileViewController alloc] init];
mainProfileViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
mainProfileViewController.userText.text = usernameTextField.text;
[self presentViewController:mainProfileViewController animated:YES completion:nil];
}
}
#end
#import <UIKit/UIKit.h>
#import "AuthenticationViewController.h"
#interface MainProfileViewController : UIViewController
{
UITextField *userText;
}
#property (retain, nonatomic) IBOutlet UILabel *resultLabel;
#property (retain, nonatomic) IBOutlet UITextField *userText;
#property (retain, nonatomic) NSString *textPass;
#end
#import "MainProfileViewController.h"
#import "AuthenticationViewController.h"
#interface MainProfileViewController ()
#end
#implementation MainProfileViewController
#synthesize resultLabel, userText, textPass;
- (void)viewDidLoad
{
userText.text = textPass;
[super viewDidLoad];
}
#end
OK, there's a few things you're doing wrong.
First off, you're instantiating a local MainProfileViewController instead of instantiating the one that you have an ivar pointing to.
The second thing that you're doing wrong is trying to send over the view from the AuthenticationViewController to the MainProfileViewController. You shouldn't do that. Instead, pass the text itself; otherwise you are just overwriting pointers, and nothing will show up.
- (IBAction)createAccount: (id)sender {
// DON'T CREATE A LOCAL VARIABLE
// MainProfileViewController *controller = [[MainProfileViewController alloc] initWithNibName:#"MainProfileViewController" bundle:nil];
mainProfileViewController = [[MainProfileViewController alloc] initWithNibName:#"MainProfileViewController" bundle:nil];
mainProfileViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
// DON'T TRY SENDING THE VIEW OVER
// mainProfileViewController.userText = usernameTextField;
mainProfileViewController.userText.text = usernameTextField.text;
[self presentViewController:mainProfileViewController animated:YES completion:nil];
}
edit: I suppose it's not required that you have an ivar to the new view controller you want to present... But the point is that you cannot instantiate one, and then set the parameter on the one you did not instantiate (it will be nil).
Check your story board and see if you connected the Outlets properly.
There should be an IBOutlet object in your view controller that you should connect in story board.
Also check if you connected the correct view controller class to the view controller in storyboard
#import <UIKit/UIKit.h>
#class MainProfileViewController;
#interface AuthenticationViewController : UIViewController
{
MainProfileViewController *mainProfileViewController;
}
#property (retain, nonatomic) IBOutlet UITextField *usernameTextField;
#end
#import "AuthenticationViewController.h"
#import "MainProfileViewController.h"
#interface AuthenticationViewController ()
#end
#implementation AuthenticationViewController
#synthesize usernameTextField;
- (IBAction)createAccount: (id)sender {
{
MainProfileViewController *controller = [[MainProfileViewController alloc] initWithNibName:#"MainProfileViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
mainProfileViewController.textpass = usernameTextField.text;
[self presentViewController:controller animated:YES completion:nil];
}
}
#end
#import <UIKit/UIKit.h>
#import "AuthenticationViewController.h"
#interface MainProfileViewController : UIViewController
{
UITextField *userText;
}
#property (retain, nonatomic) IBOutlet UILabel *resultLabel;
#property (retain, nonatomic) IBOutlet UITextField *userText;
#property (retain, nonatomic) NSString *textpass;
#end
#import "MainProfileViewController.h"
#import "AuthenticationViewController.h"
#interface MainProfileViewController ()
#end
#implementation MainProfileViewController
#synthesize resultLabel, userText;
- (void)viewDidLoad {
usertext.text=textpass;
}
#end
You need to change your code on this part...
- (IBAction)createAccount: (id)sender
{
mainProfileViewController = [[MainProfileViewController alloc] init];
mainProfileViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
mainProfileViewController.userText.text = usernameTextField.text;
[self presentViewController:mainProfileViewController animated:YES completion:nil];
}
Happy Coding...

Mac OS X using WebView object

I can't see the webview when I launch tha app..
In the delegate that's my code
#import <Cocoa/Cocoa.h>
#include "NewsViewController.h"
#interface AppDelegate : NSObject <NSApplicationDelegate>
#property (assign) IBOutlet NSWindow *window;
#property (nonatomic,strong) IBOutlet NSSplitView *splitView;
#property (nonatomic,strong) IBOutlet NewsViewController *newsViewController;
#end
#import "AppDelegate.h"
#implementation AppDelegate
- (void)dealloc
{
[super dealloc];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
// 1. Create the master View Controller
self.newsViewController = [[NewsViewController alloc] initWithNibName:#"NewsViewController" bundle:nil];
// 2. Add the view controller to the Window's content view
[self.splitView addSubview:self.newsViewController.view];
}
#end
That's my viewcontroller
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#interface NewsViewController : NSViewController{
IBOutlet WebView *web;
}
#property (assign) IBOutlet WebView *web;
#end
#import "NewsViewController.h"
#interface NewsViewController ()
#end
#implementation NewsViewController
#synthesize web;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialization code here.
}
return self;
}
-(void)loadView{
NSString *urlAddress = #"http://www.google.com/";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[web mainFrame] loadRequest:requestObj];
}
#end
if I out one label on my view in the controller everything is fine but if I put a webview I see only a grey window.
Why this?
thanks
I do believe you need to call [super loadView] in your loadView implementation.

web view did finish load labelname.hidden = yes not working?

I am very new to iOS programming and am making a simple app. the first UITabBarItem loads a page but before it loads there is a label. I am trying to make the label disappear after the web page loads but it doesn't work. I believe I need to set the web view delegate but I don't know how.
firstcontroller.h
#import <UIKit/UIKit.h>
#interface OTFFirstViewController : UIViewController
#property (strong, nonatomic) IBOutlet UIWebView *webPage;
#property (strong, nonatomic) IBOutlet UILabel *pageLoading;
#end
firstcontroller.m
#import "FirstViewController.h"
#interface FirstViewController ()
#end
#implementation FirstViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *fullURL = #"http://asdf.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_webPage loadRequest:requestObj];
}
- (void)webViewDidFinishLoad:(UIWebView *)_webPage
{
_pageLoading.hidden = YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
Insert _webPage.delegate = self; before calling loadRequest:.
You should alse modify interface definition to #interface OTFFirstViewController : UIViewController <UIWebViewDelegate>.

XCODE 4.5 - Expected Identifier... (UIWebView) - iPhone

View controller h:
#interface ViewController : UIViewController
{
IBOutlet UIWebView *WebView1;
IBOutlet UIWebView *WebView2;
IBOutlet UIWebView *WebView3;
IBOutlet UIWebView *WebView4;
IBOutlet UIWebView *WebView5;
}
#end
view controller m:
#import "ViewController.h"
#interface UIViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *myURL1 = [NSURL URLWithString:[#"http:://www.youtube.com"]];
NSURLRequest *MyRequest1 = [NSURLRequest requestWithURL:myURL1];
[WebView1 loadRequest:MyRequest1];
NSURL *myURL2 = [NSURL URLWithString:[#"http:://www.gmail.com"]];
NSURLRequest *MyRequest2 = [NSURLRequest requestWithURL:myURL2];
[WebView2 loadRequest:MyRequest2];
NSURL *myURL3 = [NSURL URLWithString:[#"http:://www.soundcloud.com"]];
NSURLRequest *MyRequest3 = [NSURLRequest requestWithURL:myURL3];
[WebView3 loadRequest:MyRequest3];
NSURL *myURL4 = [NSURL URLWithString:[#"http:://www.socialblade.com"]];
NSURLRequest *MyRequest4 = [NSURLRequest requestWithURL:myURL4];
[WebView4 loadRequest:MyRequest4];
NSURL *myURL5 = [NSURL URLWithString:[#"http:://www.fullscreen.net"]];
NSURLRequest *MyRequest5 = [NSURLRequest requestWithURL:myURL5];
[WebView5 loadRequest:MyRequest5];
}
#end
Decription:
The error is on each of the links "]". What am I dong wrong?
And I can't link/connect my outlets to the UIWebView's set up in tabs.
Please help me.
It's simple. You do not need the []'s around each string. Change it's URL to the following:
SURL *myURL4 = [NSURL URLWithString:#"http:://www.socialblade.com";
NSURLRequest *MyRequest4 = [NSURLRequest requestWithURL:myURL4];
[WebView4 loadRequest:MyRequest4];
That should solve it. If not, let me know.
Edit
Also, you are declaring your properties incorrectly, which is causing your to not connect them. You should declare your webView's like this:
View controller h:
#interface ViewController : UIViewController
#property (assign) IBOutlet UIWebView *WebView1;
#property (assign) IBOutlet UIWebView *WebView2;
#property (assign) IBOutlet UIWebView *WebView3;
#property (assign) IBOutlet UIWebView *WebView4;
#property (assign) IBOutlet UIWebView *WebView5;
#end
Then you must synthesize them in your .m
view controller m:
#import "ViewController.h"
#interface UIViewController ()
#end
#implementation ViewController
#synthesize WebView1;
#synthesize WebView2;
#synthesize WebView3;
#synthesize WebView4;
#synthesize WebView5;
After they are synthesized, you can call them as you have done. :)

using appDelegate to share data - getting "request for member in __ not in structure or union"

I've got a simple example where i have a delegate that has a string, along with a property to expose it.
myAppDelegate.h
#import <UIKit/UIKit.h>
#interface myAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *rootController;
NSString* myText;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UITabBarController *rootController;
#property (nonatomic, retain) NSString *myText;
#end
myAppDelegate.m
#import "myAppDelegate.h"
#implementation myAppDelegate
#synthesize window;
#synthesize rootController;
#synthesize myText;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}
- (void)dealloc {
[rootController release];
[window release];
[super dealloc];
}
#end
So in my main view controller, I try something like this:
myAppDelegate* ad = (myAppDelegate*)[UIApplication sharedApplication].delegate;
ad.myText = #"blah";
and I get: Request for member 'myText' in something not a structure or union
does anyone know why this is happening?
Have you tried using setter instead of dot notation?
[ad setMyText:#"blah"];