Iphone keyboard and scroll wheel not appearing - iphone

I am having trouble with a webview. This webview loads a webpage with some inputfields and some droplists. The problem is that the keyboard and the scroll wheel don't appear. I see a quick 'flash' and the cursor does go in the selected inputfield, but the keyboard doesn't appear.
I'm using xcode 4.3.3
My Appdelegate.h
#import <UIKit/UIKit.h>
#class ViewController;
#interface AppDelegate : UIResponder <UIApplicationDelegate> {
UIWindow *windowTB;
UIViewController *tabBarVC;
// UIWebView *homeWebView;
}
#property (strong, nonatomic) IBOutlet UIWindow *windowTB;
#property (strong, nonatomic) IBOutlet UIViewController *tabBarVC;
//#property (strong, nonatomic) IBOutlet UIWebView *homeWebView;
#end
Appdelegate.m (the relevant part)
#import "AppDelegate.h"
#import "tabBarVC.h"
#import "homeVC.h"
#implementation AppDelegate
#synthesize windowTB;
#synthesize tabBarVC;
//#synthesize homeWebView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self.windowTB setRootViewController:tabBarVC];
[self.windowTB makeKeyAndVisible];
return YES;
}
The homeVC.h
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#interface homeVC : UIViewController <UIWebViewDelegate>{
IBOutlet UIWebView *homeWebView;
}
#property (nonatomic, retain) UIWebView *homeWebView;
#end
And last homeVC.m
#import "AppDelegate.h"
#import "homeVC.h"
#implementation homeVC
#synthesize homeWebView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
return self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidLoad
{
[super viewDidLoad];
[homeWebView loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString:#"http://rolfdeenen.nl/test.html"]]];
}
I have been searching for a about a day now, but it just doesn't make sence to me. Can anyone help me?
Thanx!

Maybe the problem is in your webpage, because the webview has a standard behavior and you can't modify it.

Related

Adding AppDelegate.h and AppDelegate.m info in Swift

Hi I am just starting in swift and taking an iPad app and creating a iphone version.
I am trying to add annotations to a map in Swift and need to add so info to AppDelegate.h and .m to get it to work but in Swift there are is no AppDelegate.h or .m . How do I get this to work?
Here is what has to go into the AppDelegates
.h
#import <UIKit/UIKit.h>
#class AnnotationViewController;
#interface AnnotationAppDelegate : NSObject <UIApplicationDelegate> {
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet AnnotationViewController *viewController;
#end
.m
#import "AnnotationAppDelegate.h"
#import "AnnotationViewController.h"
#implementation AnnotationAppDelegate
#synthesize window=_window;
#synthesize viewController=_viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Please Help..Under tight deadline Thanks.

Two uiwebview but only one works

I am trying to implement 2 Web views using the storyboard, both linked to another online webpage.
For some reason I don't get any errors, but only the PricesViewController works.
The other VC generates a white page......
I am using these 4 files:
PricesViewcontroller.h
#import <UIKit/UIKit.h>
#interface PricesViewController : UIViewController
{
IBOutlet UIWebView *WebView; }
#property (nonatomic, retain) UIWebView *WebView;
#end
PricesViewController.m
#import "PricesViewController.h"
#interface PricesViewController ()
#end
#implementation PricesViewController #synthesize WebView;
- (void)viewDidLoad {
[WebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.sparein.be/full_pricelist.pdf"]]];
[super viewDidLoad];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self; }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. }
#end
ReservationsViewController.h
#import <UIKit/UIKit.h>
#interface ReservationsViewController : UIViewController
{
IBOutlet UIWebView *WebView2; }
#property (nonatomic, retain) UIWebView *WebView2;
#end
ReservationsViewController.m
#import "ReservationsViewController.h"
#interface ReservationsViewController ()
#end
#implementation ReservationsViewController #synthesize WebView2;
- (void)viewDidLoad {
[WebView2 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.google.be"]]];
[super viewDidLoad];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self; }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. }
#end
This may not fix your problem, but try this. Change your PricesViewController.h and ReservationsViewController.h similarly. Also, what version of Xcode are you using, and what version of iOS are you targeting? You shouldn't need #synthesize in your .m if you're using a recent version of Xcode and iOS.
#interface PricesViewController : UIViewController
#property (nonatomic, weak) IBOutlet UIWebView *WebView;
#end
IBOutlets should not be retained, as this can cause retain cycles. May not be the cause, but good programming practice anyway.

Multi-View Application Problem

I want to make multi view application. My goal is when program launch to load first view controller and then when press the button to load new tab bar controller and dismiss first controller. I try myself and I do firt step, but when tab bar controller is loaded it's appear only small tab without any tabs and old controller doesn't disappear.
This is what I've done:
SwitchAppelegate
-- Header file --
#import <UIKit/UIKit.h>
#class SwitchClass;
#interface SwitchAppDelegate : NSObject <UIApplicationDelegate> {
SwitchClass *switchClass;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet SwitchClass *switchClass;
#property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
#property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
#property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
#end
-- Implementation file --
#import "SwitchAppDelegate.h"
#implementation SwitchAppDelegate
#synthesize window=_window;
#synthesize managedObjectContext=__managedObjectContext;
#synthesize managedObjectModel=__managedObjectModel;
#synthesize persistentStoreCoordinator=__persistentStoreCoordinator;
#synthesize switchClass;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self.window addSubview:[switchClass view]];
[self.window makeKeyAndVisible];
return YES;
}
SwitchClass
-- Header file --
#import <UIKit/UIKit.h>
#class BlueClass;
#interface SwitchClass : UIViewController {
BlueClass *blueClass;
}
#property (nonatomic, retain) IBOutlet BlueClass *blueClass;
#end
-- Implementation file --
#import "SwitchClass.h"
#import "BlueClass.h"
#implementation SwitchClass
#synthesize blueClass;
-(void) viewDidLoad {
BlueClass *blue = [[BlueClass alloc] initWithNibName:#"BlueClass" bundle:nil];
self.blueClass = blue;
[self.view insertSubview:blue.view atIndex:0];
[blue release];
[super viewDidLoad];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[blueClass release];
[super dealloc];
}
BlueClass
-- Header file --
#class RedClass;
#interface BlueClass : UIViewController {
RedClass *redClass;
}
#property (nonatomic, retain) IBOutlet RedClass *redClass;
-(IBAction) switch: (id) sender;
#end
-- Implementation file --
#import "BlueClass.h"
#import "RedClass.h"
#implementation BlueClass
#synthesize redClass;
-(IBAction) switch: (id) sender {
RedClass *blue = [[RedClass alloc] initWithNibName:#"RedClass" bundle:nil];
self.redClass = blue;
// self.window.rootViewController = self.tabBarController;
[self.view addSubview:blue.view];
[blue release];
[super viewDidLoad];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[redClass release];
[super dealloc];
}
RedClass
-- Header file --
#import <UIKit/UIKit.h>
#interface RedClass : UITabBarController {
}
#end
-- Implementation file --
#import "RedClass.h"
#implementation RedClass
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
First thing is that in the appDelegate you are adding the view of SwitchClass. But SwitchClass is a UIViewController class and not UIView. so instead of that you should add your SwitchClass as a rootController like this:
self.window.rootViewController = self.switchClass;
If I were you I would just use a tab bar template provided by XCode. It will do it for you automatically.

Loading a new view before the old one iphone sdk

Probably just a simple question, but ive been building a little puzzle game and no decided i could do with a menu for it. Ive created the menu no problem i just cant get it to show before the puzzle. Ive tried changing the code in the appdelegate but its not liking it.
slider appdelegate.h
#import <UIKit/UIKit.h>
#class SliderViewController;
#class MainMenu;
#interface SliderAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MainMenu *viewController1;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet SliderViewController *viewController;
#property (nonatomic, retain) IBOutlet MainMenu *viewController1;
#end
Slider appdelegate.m
#import "SliderAppDelegate.h"
#import "SliderViewController.h"
#implementation SliderAppDelegate
#synthesize window;
#synthesize viewController;
#synthesize viewController1;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[self.window addSubview:viewController1.view];
[self.window makeKeyAndVisible];
return YES;
}
But doing that throws out an error:
error: request for member 'view' in
something not a structure or union
I know its probably a stupid question but could anyone help please.
You need to import that class and make alloc the object first see this
Slider appdelegate.m
#import "SliderAppDelegate.h"
#import "SliderViewController.h"
#import "MainMenu.h"//change here
#implementation SliderAppDelegate
#synthesize window;
#synthesize viewController;
#synthesize viewController1;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
viewController = [[[MainMenu alloc] initWithNibName#"MainMenu" bundle:nil] autorelease]; // and here
[self.window addSubview:viewController1.view];
[self.window makeKeyAndVisible];
return YES;
}

change a label from another view

I have a label on my main View. I have a button which brings me to another view. On it I have a button to change my label which is on the main view.
How can I do this? I included a projet, could someone help me please...
I usually use a delegate protocol:
in the second view h add :
#protocol viewControllerDelegate;
#interface viewController : UIView
id < viewControllerDelegate > delegate;
#property (nonatomic, assign) id < QuickViewControllerDelegate > delegate;
#end
#protocol viewControllerDelegate
- (void)viewController:(ViewController *)controller stringForLabel:(NSString*)string;
#end
in the second view m file call:
[delegate quickViewController:self
stringForLabel:#"your string"];
in the main view h file add: , like that:
#interface MainView:UIViewController<viewControllerDelegate>
in the main view m file:
first: when you init the second view don't forget to add:
secondview.delegate = self;
other wise it wont work.
second: add the delegate function:
- (void)viewController:(ViewController*)controller stringForLabel:(NSString*)string{
//set the label from the string passed
lable.text = string;
}
hope it will help
shani
O.K i usually don't do that but for now...
this are your files after i have change them -
View1 .h (try to name those files with a capital letter);
#import <UIKit/UIKit.h>
#protocol View1Delegate;
#interface View1 : UIViewController {
id <View1Delegate> delegate;
IBOutlet UIButton *btn_changelbl;
IBOutlet UIButton *btn_back;
}
#property (nonatomic, assign) id <View1Delegate> delegate;
#property (nonatomic,retain) IBOutlet UIButton *btn_changelbl;
#property (nonatomic,retain) IBOutlet UIButton *btn_back;
-(IBAction) backToMain:(id)sender;
-(IBAction) changeLabel:(id)sender;
#end
#protocol View1Delegate
- (void)view1:(View1*)controller labelNeedsChage:(BOOL)needsChange stringForLabel:(NSString*)string;
#end
View1.m
#import "View1.h"
#import "testViewController.h"
#implementation View1
#synthesize delegate;
#synthesize btn_changelbl;
#synthesize btn_back;
-(IBAction) backToMain:(id)sender {
[self dismissModalViewControllerAnimated:YES];
[delegate view1:self labelNeedsChage:NO stringForLabel:nil];
}
-(IBAction) changeLabel:(id)sender{
[delegate view1:self labelNeedsChage:YES stringForLabel:#"new text"];
[self dismissModalViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
}
- (void)dealloc {
[btn_changelbl release];
[btn_back release];
[super dealloc];
}
#end
TestViewController.h
#import <UIKit/UIKit.h>
#import "View1.h"
#interface testViewController : UIViewController<View1Delegate> {
IBOutlet UILabel *lb_test;
IBOutlet UIButton *btn_changeView;
}
#property (nonatomic,retain) IBOutlet UILabel *lb_test;
#property (nonatomic,retain) IBOutlet UIButton *btn_changeView;
-(IBAction) changeView:(id)sender;
#end
TestViewController.m
#import "testViewController.h"
#import "view1.h"
#implementation testViewController
#synthesize lb_test;
#synthesize btn_changeView;
-(IBAction) changeView:(id)sender {
View1 *myView = [[View1 alloc] init];
myView.delegate=self;
[self presentModalViewController:myView animated:YES];
}
- (void)view1:(View1*)controller labelNeedsChage:(BOOL)needsChange stringForLabel:(NSString*)string{
if(needsChange){
lb_test.text=string;
}
}
- (void)dealloc {
[lb_test release];
[btn_changeView release];
[super dealloc];
}
#end
Thats it.
by the way:
you had many small mistakes that i have fixed. look at the fixes to try to understand them.