Search Results

Search found 528 results on 22 pages for 'viewcontroller'.

Page 1/22 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Setting ViewController delegates in iPhone runtime

    - by Stein Rune Risa
    I am writing an iPhone application and needed to use the address book functionality. For this to work, it is necessary to specify a ABPeoplePickerNavigationControllerDelegate on the ViewController. The problem is that I am creating all fields and buttons dynamically runtime, and thus does not have any custom ViewController - using only UIViewController class. My question is then - how can I specify the delegate runtime without having to create a ViewController class just for this purpose.

    Read the article

  • UITabBarControllerDelegate compare value of viewController

    - by T9
    I have a tabBar with 4 tabs on it, and I want to perform some action when a specific tab is selected, so I have uncommented the UITabBarControllerDelegate in the xxAppDelegate.m I also wanted to see the value that was being sent logged in the console - in order to test my "if" statement. However this is where I got stumped. // Optional UITabBarControllerDelegate method - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"%@", viewController); } The console dutifully logged any selected controller that had been selected, but in this particular format: <MyViewController: 0x3b12950> Now, I wasn't expecting the square brackets or the colon or the Hex. So my question is how do I format my IF statement? This is what I thought would work but I get an error mentioned further down. // Optional UITabBarControllerDelegate method - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"%@", viewController); if (viewController == MyViewController) { //do something nice here … }; } ... The error is "Expected expression before 'MyViewController'" Anyone know how I should be doing this?

    Read the article

  • Press a Button and open a URL in another ViewController

    - by Dennis Borup Jakobsen
    I am trying to learn Xcode by making a simple app. But I been looking on the net for hours (days) and I cant figure it out how I make a button that open a UIWebView in another ViewController :S first let me show you some code that I have ready: I have a few Buttons om my main Storyboard that each are title some country codes like UK, CA and DK. When I press one of those Buttons I have an IBAction like this: - (IBAction)ButtonPressed:(UIButton *)sender { // Google button pressed NSURL* allURLS; if([sender.titleLabel.text isEqualToString:@"DK"]) { // Create URL obj allURLS = [NSURL URLWithString:@"http://google.dk"]; }else if([sender.titleLabel.text isEqualToString:@"US"]) { allURLS = [NSURL URLWithString:@"http://google.com"]; }else if([sender.titleLabel.text isEqualToString:@"CA"]) { allURLS = [NSURL URLWithString:@"http://google.ca"]; } NSURLRequest* req = [NSURLRequest requestWithURL:allURLS]; [myWebView loadRequest:req]; } How do I make this open UIWebview on my other Viewcontroller named myWebView? please help a lost man :D

    Read the article

  • Get nul value from one ViewController to one ViewController

    - by sovannarith
    I have 2 ViewControllers namely V1 and V2. I want to pass value from V2 to V1 but I get value 0 for countV1 in V1. I saw more questions in stackoverflow but I can't deal with this small problem. I use ARC. In V1 .h file @property(nonatomic,unsafe_unretained) int countV1; .m file @synthesize countV1; In V2 .m file int countV2 = 1; V1 *v1 = [V1 alloc] initWithNibName:@"V1" bundle:nil]; v1.countV1 = countV2;

    Read the article

  • ViewController in programming

    - by Vishwas Gagrani
    ViewController is a term for classes that handle views in a framework. This is especially used in MVC frameworks. I go through various projects, written by various programmers, who implement MVC in different ways. Especially, i get confused, about the relation between the MainView ( parent view ) and some CustomView ( widget etc) in the framework. I personally pass reference of the MainView into the ViewController to be instantiated. All the subviews of ViewController are added to that reference of MainView. Additionally, ViewController itself is added as a child of MainView. Like this : Want to know, if this is the right way to relate each other ?

    Read the article

  • Passing data from one viewcontroller to another

    - by user1392515
    I subclassed two view controllers. The first one is supposed to pass data, a NSUrl object to the second one. .m of the first one: NSURL *temp = [NSURL URLWithString:@"http://example.com"]; UIViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"]; presentationsFullScreen_ViewController.urlToUse = temp; .h of the second one: #import <UIKit/UIKit.h> @interface PresentationsFullScreen_ViewController : UIViewController { NSURL *urlToUse; } @property (nonatomic,retain) NSURL *urlToUse; It is obviously not working and not compiling,telling me essentially that I didn't subclass it and that the property urlToUse is not found on UIViewController. How do I subclass correctly? Thanks!

    Read the article

  • Can i pop to Specific ViewController?

    - by Ankit Vyas
    Hello!I am using Navigation Based Application.I push First ViewController to Second ViewController and From Second ViewController to Third ViewController Now I want to Pop From Third ViewController to First ViewController.I am Performing This task using the Below Code but i application get's Terminate.Please any body give me some proper Guidelines.I can't use pop to RootViewController because it's Different ViewController.Thanks in Advance... In Third ViewControler i have Written this: FirstViewCtr *x=[[FirstViewCtr alloc] initWithNibName:@"FirstViewCtr" bundle:nil]; [self.navigationController popToViewController:x animated:NO];

    Read the article

  • How load WebView with another URL when navigated through tab bar viewController

    - by TechFusion
    Hello, I have created window based application, root controller as Tab bar controller. WebView is being loaded in Tab bar interfaced ViewController's View.WebView is created using IB.WebView object declared in ViewController as per below. //ViewController.h @interface ViewController:UIViewController{ IBOutlet UIWebview *Webview; } @property(nonatomic,retain)IBOutlet UIWebview *Webview; @end I am calling [WebView loadrequest] method in -viewDidLoad method and stopLoading will be called in -viewWillDisappear method. I am again reload it in -viewWillAppear:animated method to load it again when tab bar is pressed. //ViewController.m @implementation viewcontroller @synthesize Webview; -(void)viewDidLoad{ [super viewDidLoad]; [self.Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"www.apple.com"]]]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.Webview reload]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.Webview stopLoading]; } I am releasing WebView in -ViewDidUnload method -(void)viewDidUnload{ [super viewDidUnload]; [Webview release]; } -(void)dealloc{ [Webview release]; [super dealloc]; } Does Webview released correctly ? Here how to kill connection with URL when ViewWillDisappear method called ? How to load View with Different URL then it's loaded in -viewDidLoad method when ViewController interfaced tab is pressed ? Means if naviagated from one tab to another that ViewController interface tab which has WebView should load request with another URL. Does it correct to call [self.Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"www.stackoverflow.com"]]]; this method again in -viewWillAppear:animated method to load with another URL ? Thanks,

    Read the article

  • How to add a subclass to a viewcontroller in storyboard

    - by Ken Barlo
    Here's what I've created I created a view controller element (in storyboard) I created a new viewcontroller .h and .m file Here's my issue Can't seem to figure out how to get the content that I've added to the .m file to show up on the view controller element in the storyboard once the app is launched and the selection for that view controller element is made in the iPhone simulator. Although I am able to see content that is already added to a .m file on the home screen and activity screen when the selection is made in the iPhone simulator. Hope that makes sense, if not please ask and I'll be more than happy to provide more info.

    Read the article

  • How to create Dictionary object in AppDelegate to access objectkey in another ViewController

    - by TechFusion
    Hello, I have created Window Based application and tab bar controller as root controller. My objective is to store Text Field data values in one tab bar VC and will be accessible and editable by other VC and also retrievable when application start. I am looking to use NSDictionary class in AppDelegate so that I can access stroed Data Values with keys. //TestAppDelegate.h @interface { ..... .... NSDictionary *Data; } @property (nonatomic, retain) NSDictionary *Data; //TestAppDelegate.m #import "TestAppDelegate.h" NSString *kNamekey =@"Namekey"; NSString *kUserIDkey =@"UserIDkey"; NSString *kPasswordkey =@"Passwordkey"; @implemetation TestAppDelegate @synthesize Data; -(void)applicationDidFinishLaunching:(UIApplication)application { NSString *NameDefault; NSString *UserIDdefault; NSString *Passworddefault; NSString *testvalue = [[NSUserDefaults standardUserDefaults] stringForKey: kNamekey]; if(testvalue == nil) { NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: NameDefault, kNamekey, UserIdefault kUserIDkey, Passwordefault kPasswordkey, nil]; self.Data = appDefaults; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; [[NSUserDefaults standardUserDefaults] synchronize]; } else { } } Here ViewController is ViewController of Navigation Controller which is attached with one tab bar.. I have attached xib file with ViewController //ViewController.h @interface IBOutlet UITextField *Name; IBOutlet UITextField *UserId; IBOutlet UITextField *Password; } @property(retain,nonatomic) IBOutlet UITextField *Name @property(retain,nonatomic) IBOutlet UITextField *UserId; @property(retain,nonatomic) IBOutlet UITextField *Password; -(IBAction)Save:(id)sender; @end Here in ViewController.m I want to store Text Field input data with key which are defined in AppDelegate. I have linked Save Barbutton with action. Here I am not getting how to access NSDictionary class with object and keys in ViewController. //ViewController.m -(IBAction)Save:(id)sender{ TestAppDelegate *appDelegate = (TestAppDelegate*)[[UIApplication sharedApplication] delegate]; //Here how to access knamekey here to set object(Name.test) value with key } Please guide me about this. Thanks,

    Read the article

  • Memory Problem - Release whole ViewController ?

    - by Sebastian
    Hi, I'm using a TabBarController with a few Tabs and I have memory problems when switching through the tabs and the contents. Is there a way to release and dealloc everything when I go to another ViewController ? So when I am in Tab#1 with ViewController #1 and I go to Tab#2 with ViewController #2, how can I free all the memory ViewController #1 took ? Thx ! Sebastian

    Read the article

  • How can i call UItimer form one viewcontroller from unother viewcontroller?

    - by Bala
    At first time i call the timer like this in Third viewcontroller timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(targetMethod) userInfo:nil repeats:NO]; Then timer called the targetMethod -(void)targetMethod { First * sVC = [[First alloc] initWithNibName:@"First" bundle:[NSBundle mainBundle]]; [self presentModalViewController:sVC animated:YES]; [sVC release]; [timer invalidate]; } First viewcontroller opened.. In First viewcontroller had one button.In button action i wrote (IBAction) Action:(id)sender { [self dismissModalViewControllerAnimated:YES]; Third *BVC=[[Third alloc]init]; [Bvc TimerStart]; Timestart is function i start timer in this function.. i want to call Third viewcontroller timer function this place } timer started..But view didn't open (first )viewcontroller....... Please help me......

    Read the article

  • Simple ViewController / View, remove white bar?

    - by fuzzygoat
    I am just looking at setting up a simple viewController programatically, I have a ViewController.xib file that I have set the background color to RED in interface builder. I have also added the following to my AppDelegate.m @implementation syntax_MapViewAppDelegate @synthesize window; -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { viewController = [[MapViewController alloc] init]; [window addSubview:[viewController view]]; [window makeKeyAndVisible]; return YES; } -(void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end When I run the code it does what I expect apart from the white bar at the bottom of the screen, can anyone give me any pointers in how to remove this? I have a feeling I might need to position the view within the window, but I am not sure how? cheers Gary

    Read the article

  • How can i call NStimer form one viewcontroller from unother viewcontroller?

    - by Bala
    At first time i call the timer like this in Third viewcontroller timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(targetMethod) userInfo:nil repeats:NO]; Then timer called the targetMethod -(void)targetMethod { First * sVC = [[First alloc] initWithNibName:@"First" bundle:[NSBundle mainBundle]]; [self presentModalViewController:sVC animated:YES]; [sVC release]; [timer invalidate]; } First viewcontroller opened.. In First viewcontroller had one button.In button action i wrote (IBAction) Action:(id)sender { [self dismissModalViewControllerAnimated:YES]; Third *BVC=[[Third alloc]init]; [Bvc TimerStart]; Timestart is function i start timer in this function.. i want to call Third viewcontroller timer function this place } timer started..But view didn't open (first )viewcontroller....... Please help me......

    Read the article

  • Remove UIViewController from UIScrollView?

    - by tobi
    Hi, i add different View with (setPageID) to a ScrollView, but know i get a Memory problem on rotaion and i want to remove the actualy not showed view... how can i do this or how can i remove the memory problem? Thanks!!! - (void)setPageID:(int)page { if (page < 0) return; if (page >= self.listOfItems.count) return; CGFloat cx = 0; ScrollingViewStep *controller = [viewControllers objectAtIndex:page]; if ((NSNull *)controller == [NSNull null]) { controller = [[ScrollingViewStep alloc] init]; [viewControllers replaceObjectAtIndex:page withObject:controller]; [controller release]; } if (nil == controller.view.superview) { if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) { cx = 768.0 * page; controller.view.frame = CGRectMake(cx, 0.0 , 768.0f, 926.0f); } else { cx = 1024.0 * page; controller.view.frame = CGRectMake(cx, 0.0 , 1024.0f, 670.0f); } [controller setView:ItemID PageID:page Text:[[self.listOfItems objectAtIndex:page] objectForKey:@"step"]]; [scrollView addSubview:controller.view]; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { CGFloat cx2 = 0; for (int i = 0; i < [self.viewControllers count]; i++) { ScrollingViewStep *viewController = [self.viewControllers objectAtIndex:i]; if ((NSNull *)viewController != [NSNull null]) { if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) { cx2 = 768.0 * i; viewController.view.frame = CGRectMake(cx2, 0.0 , 768.0f, 926.0f); [viewController repos]; } else { cx2 = 1024.0 * i; viewController.view.frame = CGRectMake(cx2, 0.0 , 1024.0f, 670.0f); [viewController repos]; } } } if((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) { CGRect frame = scrollView.frame; frame.origin.x = 768 * currentPageInScrollview; frame.origin.y = 0; [scrollView scrollRectToVisible:frame animated:NO]; } else { CGRect frame = scrollView.frame; frame.origin.x = 1024 * currentPageInScrollview; [scrollView scrollRectToVisible:frame animated:NO]; } pageControlIsChangingPage = YES; return YES; } - (void)didReceiveMemoryWarning { int currentPage = currentPageInScrollview; NSLog(@"MEMORY"); // unload the views+controllers which are no longer visible UIViewController *l; for (int i = 0; i < [self.viewControllers count]; i++) { ScrollingViewStep* viewController = [self.viewControllers objectAtIndex:i]; if((NSNull *)viewController != [NSNull null]) { if(i < currentPage-1 || i > currentPage+1) { [self.viewControllers replaceObjectAtIndex:i withObject:[NSNull null]]; } } } [super didReceiveMemoryWarning]; }

    Read the article

  • Go from a ViewController, to an other section of a TabBar

    - by Seraphin
    Hi, I'm currently doing an application with 5 View Controllers and a tabBar on the bottom. For this application, I need to set up a button in viewController(1) which can send me to an other viewController(3), but without touching the tabBar (it will be hidden for the viewController(1)). I basically know how to use a tabBar, but I don't know wich functions I can use to do that. Thanks in advance! Séraphin

    Read the article

  • How to set interface method between two viewController to pass paramter in Navigation Controller

    - by TechFusion
    Hello, I have created Window based application, root controller as Tab Bar controller. One Tab bar has Navigation controller. Navigation controller's ViewControlller implementation, I am pushing Viewcontroller. I am looking to pass parameter from Navigation Controller's View controller to pushed View Controller. I have tried to pass as per below method. //ViewController.h @interface ViewController:UIViewController{ NSString *String; } @property(copy, nonatomic)NSString *String; @end //ViewController.m #import "ViewController1.h" ViewController1 *level1view = [[ViewController alloc]init]; level1view.hideBottomBarWhenPushed = YES; level1view.theString = String; [self.navigationController pushViewController:level1view animated:YES]; [level1view release]; //ViewController1.h NSString *theString; @property(copy, nonatomic)NSString *theString; This is working fine. but I want to pass more than one parameter like Integer and UITextFiled Values so how to do that? Is there any Apple Doc that I can get idea about this? Thanks,

    Read the article

  • Rotation of ViewController in TabbarController

    - by hanno
    I have a custom UIViewController in a UITabbarController and want to respond to rotation events. When a rotation occurs, the tabbarcontroller and the viewcontroller get rotated. However, the view in the viewcontroller doesn't get redrawn properly: the layout doesn't autoresize and it is black on parts of the screen. The strange thing is that it works when I go to another tab and the back again to my original viewcontroller. What could possibly be wrong? I checked that didRotateFromInterfaceOrientation:fromInterfaceOrientation is being called. However, the view.frame.size values are still the old ones from before the rotation. That's probably not correct.

    Read the article

  • NSNotification postNotificationName in AppDelegate but NSNotificationCenter in ViewController?

    - by James Testa
    I can't get the selector method, receiveChatText, in the NSNotificationCenter to execute and I am wondering if the problem is because the NSNotification postNotificationName is in AppDelegate.m but NSNotificationCenter is in ViewController.m? I.E. can the postNotificationName know that the NSNotificationCenter is in another viewController file or is that something I need to tell it? In a viewController.m I have -(id)init { self = [super init]; if(self){ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveChatText:) name:ChatMessageReceived object:nil]; return self; } - (void)receiveChatText:(NSNotification *)note { NSLog(@"received chat text"); } and in the top level AppDelegate.m file I have the following: -(void) didReceiveMessage { [[NSNotificationCenter defaultCenter] postNotificationName:ChatMessageReceived object:nil userInfo:nil]; } Any ideas what could stop receiveChatText from being executed when didReceiveMessage is called?

    Read the article

  • How to add UIview over a ViewController and its NavigationController

    - by Roxee Man
    I have a ViewController with a NavigationController and I want to add a translucent UIView with some Buttons over the ViewController when I press a ViewController button, the problem is that I can not put the UIView over the NavigationBar. How can I solve this? This is my code ( Very simple) -(void)setOpacityView { opacityVw = [[UIView alloc] initWithFrame:self.view.bounds]; opacityVw.backgroundColor = [[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.8]; WPCustomButton *closeBtn = [[WPCustomButton alloc] initWithFrame:CGRectMake(230, 10, 80, 20)]; [closeBtn setTitle:@"Close X" forState:UIControlStateNormal]; [closeBtn setBackgroundColor:[UIColor clearColor]]; [closeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [closeBtn addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside]; [opacityVw addSubview:closeBtn]; } // --------------------------------------------------------------------------------------------------------------------- #pragma mark - Button methods -(void) closeView { [opacityVw removeFromSuperview]; } -(void)setProfileImage { [self setOpacityView]; [self.view addSubview:opacityVw]; }

    Read the article

  • Using CATransition in a viewController

    - by eco_bach
    Hi I'm trying to implement the ViewTransitions code sample from Apple, but putting all the logic in my viewController instead of my applicationDelegate class. I'm getting a bizarre error when I try to compile. I'm importing QuartzCore in my viewcontroller implementation as #import _kCATransitionFade", referenced from: _kCATransitionFade$non_lazy_ptr in ViewTransitionsAsViewControllerViewController.o (maybe you meant: _kCATransitionFade$non_lazy_ptr) Anyone have any ideas?

    Read the article

  • performSelectorInBackground, notify other viewcontroller when done.

    - by Michiel
    Hi, I have a method used to save an image when the user clicks Save. I use performSelectorInBackground to save the image, the viewcontroller is popped and the previous viewcontroller is shown. I want the table (on the previousUIViewController) to reload its data when the imagesaving is done. How can I do this? The save method is called like this: [self performSelectorInBackground:@selector(saveImage) withObject:nil]; [self.navigationController popViewControllerAnimated:YES];

    Read the article

  • Sub-viewController doesn't get autorotation notifications, bug?

    - by Shizam
    If I have a view (and its controller) and I override the willAnimateRotationToInterfaceOrientation method so I can respond to autorotation events everything works fine and dandy. Now if I create another viewController and add its view to the first viewController's view via: [firstViewController.view addSubview:secondViewController.view] The secondViewController's willAnimateRotationToInterfaceOrientation method isn't called. What gives? Thanks, Sam

    Read the article

  • error prepareForSegue between a viewController and a tableViewController

    - by beta
    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"My_TableView"]) { MyTableViewController *destViewController = segue.destinationViewController; destViewController.data = data; } } Hi, I have a problem doing a segue (modal) between a ViewController to a TableViewController. The name of the segue between the ViewController and the NavigationController is "My_TableView". Compiler gives me this error: unrecognized selector sent to instance 0x9275b50 what's the problem?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >