Search Results

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

Page 8/22 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Interchanging presentModalViewController and pushViewController

    - by Neffster
    I am using a sample ViewController that is displayed in the sample program as a presentModalViewController. However, I want to use pushViewController on the UIViewController instead. The problem is that when I switch to pushViewController, the ViewController no displays properly. Functions in the ViewController are called, but I don't see anything. I change back to presentModalViewController and everything works. The question is what do I need to do to make pushViewController work? FCVC *fcVC; NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"fcVC" owner:self options:nil]; fcVC = [array objectAtIndex:0]; A. [self presentModalViewController:fcVC animated:YES]; // "WORKS" or B. [self.navigationController pushViewController:fcVC animated:YES]; // "Doesn't work

    Read the article

  • Declaring CustomViewController?

    - by fuzzygoat
    I have noticed in some of my older apps that in situations where I have added a custom View Controller I have not changed the View Controller class in the application delegate. For example, below I have created a CustomViewController class but have declared viewController as UIViewController. @interface ApplicationAppDelegate: NSObject <UIApplicationDelegate> { UIWindow *window; UIViewController *viewController; } My question is, both work, but for correctness should I be writing this as follows: @class CustomViewController; @interface ApplicationAppDelegate: NSObject <UIApplicationDelegate> { UIWindow *window; CustomViewController *viewController; } gary

    Read the article

  • differing methods of alloc / init / retaining an object in objective-c

    - by taber
    In several pieces of sample objective-c code I've seen people create new objects like this: RootViewController *viewController = [[RootViewController alloc] init]; self.rootViewController = viewController; // self.rootViewController is a (nonatomic,retain) synthesized property [viewController release]; [window addSubview: [self.rootViewController view]]; Is that any different "behind the scenes" than doing it like this instead? self.rootViewController = [[RootViewController alloc] init]; [window addSubview: [self.rootViewController view]]; Seems a bit more straightforward/streamlined that way so I'm wondering why anyone would opt for the first method. Thanks!

    Read the article

  • call method in a subclass of UIView

    - by rdesign
    Hey, I've got a UIViewController and an own class, a subclass of UIView. In my ViewController I make a instance of the uiview. If I tap the uiview a function gets called within it and an overlay appears. TO get rid of that overlay later the user has to tap somewhere on the screen(besides the instance of my class) How do I tell my class to dismiss the overlay? I already thought of delegate. So my thoughts were to make a MyUIViewControllerdelegate. If my viewcontroller receives a tap the delegate should be called. THe only problem is how do I tell my subclass that it should receive that delegate? I Have no instance of my viewcontroller in my subclass so I can not set the delegate. Any Ideas? Hope my problem is clear :) Thanks a lot

    Read the article

  • What class should manage/control the CALayers in my view using proper MVC?

    - by wanderlust
    I have a ViewController with a view (UIView). I need to handle touches, run some logic, check against model data, and and add and remove sublayers to the view based on those touches. Then I need to update the model based on the results. Should I have: ViewController - manage touches, get/set model data, add/remove sublayers UIView CALayer Sublayers or Controller (NSObject) - get/set data ViewController - manage touches, add/remove sublayers UIView CALayer Sublayers or Controller (NSObject) - get/set data CustomView - manage touches, add/remove sublayers CALayer Sublayers Or is it something else all together? No matter what I try, it "feels" awkward. SVN is my friend. Can you guys help a girl (with architectural issues) out?

    Read the article

  • Common views in viewControllers - Code re-usability

    - by Nitish
    I have few common views in most of my viewControllers. What I noticed is that I can reuse single code for all viewControllers which is absolutely wise. For this I decided to create a class Utils which has static methods like +(void)createCommonViews:(float)yAxis:(NSString*)text; In my case common views are three labels and two images. Problem : I am not able to add these views from Utils. I am wondering how can I send self as a parameter so that I may add the views from Utils. It may be wrong to add views outside the viewController. In that case what can be the solution? Taking all these views in a UIView, setting return type of Utils method as UIView and then adding UIView to viewController(after calling method from viewController) might solve my problem. But what I am looking for is some other solution. Thanks, Nitish

    Read the article

  • Passing arguments to UILabel [ 2 ] *

    - by DesperateLearner
    I'm trying to call a method of the below (Scroll animation class) type from a viewcontroller class. -(void)CreateLabel:(CGRect )frame andLabel:(UILabel *[NUM_LABELS])label andview:(UIView *)view; I got some errors when I tried passing the argument. Any suggestion on how to call this? This is how I called that method ScrollAnimation *newAnimation = [[ScrollAnimation alloc] init]; [newAnimation CreateLabel:CGRectMake(0, 50, 300,30) andLabel:animateLabel[NUM_LABELS] andview:self.view]; I have the error /Volumes/Red Drive/CarTransition/CarTransition/ViewController.m:120:66: Implicit conversion of an Objective-C pointer to 'UILabel **' is disallowed with ARC /Volumes/Red Drive/CarTransition/CarTransition/ViewController.m:120:66: Incompatible pointer types sending 'UILabel *__strong' to parameter of type 'UILabel **'

    Read the article

  • Load custom class properly

    - by LinusAn
    I have a custom class which I want to "load" inside the firstViewController and then access it from other classes by segues. My Problem is, I can't even access and change the instance variable inside the firstViewController. Somehow I'm "loading" it wrong. Here is the code I used until now: inside viewController.h @property (strong, nonatomic) myClass *newClass; inside viewController.m @synthesize newClass; I then try to access it by: self.newClass.string = @"myString"; if(newClass.string == @"myString"){ NSLog(@"didn't work"); } Well, I get "didn't work". Why is that? When I write myClass *newClass = [myClass new]; It does work. But the class and its properties gets overwritten every time the ViewController loads again. What would you recommend? Thank you very much.

    Read the article

  • Simple iOS glDrawElements - BAD_ACCESS

    - by user699215
    You can copy paste this into the default OpenGl template created in Xcode. Why am I not seeing anything :-) It is strange as the glDrawArrays(GL_TRIANGLES, 0, 3); is working fine, but with glDrawElements(GL_TRIANGLE_STRIP, sizeof(indices)/sizeof(GLubyte), GL_UNSIGNED_BYTE, indices); Is giving BAD_ACCESS? Copy paste this into Xcode default OpenGl template: ViewController #import "ViewController.h" #define BUFFER_OFFSET(i) ((char *)NULL + (i)) // Uniform index. enum { UNIFORM_MODELVIEWPROJECTION_MATRIX, UNIFORM_NORMAL_MATRIX, NUM_UNIFORMS }; GLint uniforms[NUM_UNIFORMS]; // Attribute index. enum { ATTRIB_VERTEX, ATTRIB_NORMAL, NUM_ATTRIBUTES }; @interface ViewController () { GLKMatrix4 _modelViewProjectionMatrix; GLKMatrix3 _normalMatrix; float _rotation; GLuint _vertexArray; GLuint _vertexBuffer; NSArray* arrayOfVertex; } @property (strong, nonatomic) EAGLContext *context; @property (strong, nonatomic) GLKBaseEffect *effect; - (void)setupGL; - (void)tearDownGL; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; GLKView *view = (GLKView *)self.view; view.context = self.context; view.drawableDepthFormat = GLKViewDrawableDepthFormat24; [self setupGL]; } - (void)dealloc { [self tearDownGL]; if ([EAGLContext currentContext] == self.context) { [EAGLContext setCurrentContext:nil]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; if ([self isViewLoaded] && ([[self view] window] == nil)) { self.view = nil; [self tearDownGL]; if ([EAGLContext currentContext] == self.context) { [EAGLContext setCurrentContext:nil]; } self.context = nil; } // Dispose of any resources that can be recreated. } GLuint vertexBufferID; GLuint indexBufferID; static const GLfloat vertices[9] = { -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5 }; static const GLubyte indices[3] = { 0, 1, 2 }; - (void)setupGL { [EAGLContext setCurrentContext:self.context]; // [self loadShaders]; self.effect = [[GLKBaseEffect alloc] init]; self.effect.light0.enabled = GL_TRUE; self.effect.light0.diffuseColor = GLKVector4Make(1.0f, 0.4f, 0.4f, 1.0f); glEnable(GL_DEPTH_TEST); // glGenVertexArraysOES(1, &_vertexArray); // glBindVertexArrayOES(_vertexArray); glGenBuffers(1, &vertexBufferID); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferID); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glGenBuffers(1, &indexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferID); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); glEnableVertexAttribArray(GLKVertexAttribPosition); glVertexAttribPointer(GLKVertexAttribPosition, // Specifies the index of the generic vertex attribute to be modified. 3, // Specifies the number of components per generic vertex attribute. Must be 1, 2, 3, 4. GL_FLOAT, // GL_FALSE, // 0, // BUFFER_OFFSET(0)); // // glBindVertexArrayOES(0); } - (void)tearDownGL { [EAGLContext setCurrentContext:self.context]; glDeleteBuffers(1, &_vertexBuffer); glDeleteVertexArraysOES(1, &_vertexArray); self.effect = nil; } #pragma mark - GLKView and GLKViewController delegate methods - (void)update { float aspect = fabsf(self.view.bounds.size.width / self.view.bounds.size.height); GLKMatrix4 projectionMatrix = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(65.0f), aspect, 0.1f, 100.0f); self.effect.transform.projectionMatrix = projectionMatrix; GLKMatrix4 baseModelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -4.0f); baseModelViewMatrix = GLKMatrix4Rotate(baseModelViewMatrix, _rotation, 0.0f, 1.0f, 0.0f); // Compute the model view matrix for the object rendered with GLKit GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, -1.5f); modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f); modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix); self.effect.transform.modelviewMatrix = modelViewMatrix; // Compute the model view matrix for the object rendered with ES2 modelViewMatrix = GLKMatrix4MakeTranslation(0.0f, 0.0f, 1.5f); modelViewMatrix = GLKMatrix4Rotate(modelViewMatrix, _rotation, 1.0f, 1.0f, 1.0f); modelViewMatrix = GLKMatrix4Multiply(baseModelViewMatrix, modelViewMatrix); _normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL); _modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix); _rotation += self.timeSinceLastUpdate * 0.5f; } int i; - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { glClearColor(0.65f, 0.65f, 0.65f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // glBindVertexArrayOES(_vertexArray); // Render the object with GLKit [self.effect prepareToDraw]; //glDrawArrays(GL_TRIANGLES, 0, 3); // Render the object again with ES2 // glDrawArrays(GL_TRIANGLES, 0, 3); glDrawElements(GL_TRIANGLE_STRIP, sizeof(indices)/sizeof(GLubyte), GL_UNSIGNED_BYTE, indices); } @end

    Read the article

  • Is it a good pattern that no objects should know more than what it needs to know?

    - by Jim Thio
    I am implementing a viewController class. The view controller class got NSNotification when the Grabbing class start or finish updating. I have 2 choices. I can make the grabbing class to provide a public read only property so all other classes can know whether it is still uploading. Or I can let view Controller to listen to 2 different events. Start updating and finish updating events. The truth is the viewController do need to know whether the grabbing class is still updating or not at any other time. So I am thinking of creating 2 events would be a better way to go. Actually, what do you think?

    Read the article

  • Connect players with same phone language settings

    - by Abin George
    I am working on a turn-based multiplayer game using game center. The game also use Spanish localisation. It is enabled by reading the device language settings. Now my requirement is: When i start a turn based match, my opponent should have the same language setting in his/her phone as I am having. How can I make this possible. I use the following code to connect - (void)findTurnBasedMatchWithViewcontroller:(UIViewController *)viewController forDelegate:(id)argDelegate { self.delegate = argDelegate; presentingViewController = viewController; GKMatchRequest *request = [[GKMatchRequest alloc] init]; request.minPlayers = 2; request.maxPlayers = 2; [manager setCurrentGameType:kTurnBased]; GKTurnBasedMatchmakerViewController *mmvc = [[GKTurnBasedMatchmakerViewController alloc] initWithMatchRequest:request]; mmvc.turnBasedMatchmakerDelegate = self; mmvc.showExistingMatches = NO; [presentingViewController presentViewController:mmvc animated:YES completion:^(void) { }]; }

    Read the article

  • UIButton performance in UITableViewCell vs UIView

    - by marcel salathe
    I'd like to add a UIButton to a custom UITableViewCell (programmatically). This is easy to do, but I'm finding that the "performance" of the button in the cell is slow - that is, when I touch the button, there is quite a bit of delay until the button visually goes into the highlighted state. The same type of button on a regular UIView is very responsive in comparison. In order to isolate the problem, I've created two views - one is a simple UIView, the other is a UITableView with only one UITableViewCell. I've added buttons to both views (the UIView and the UITableViewCell), and the performance difference is quite striking. I've searched the web and read the Apple docs but haven't really found the cause of the problem. My guess is that it somehow has to do with the responder chain, but I can't quite put my finger on it. I must be doing something wrong, and I'd appreciate any help. Thanks. Demo code: ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> @property UITableView* myTableView; @property UIView* myView; ViewController.m #import "ViewController.h" #import "CustomCell.h" @implementation ViewController @synthesize myTableView, myView; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { [self initMyView]; [self initMyTableView]; } return self; } - (void) initMyView { UIView* newView = [[UIView alloc] initWithFrame:CGRectMake(0,0,[[UIScreen mainScreen] bounds].size.width,100)]; self.myView = newView; // button on regularView UIButton* myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [myButton addTarget:self action:@selector(pressedMyButton) forControlEvents:UIControlEventTouchUpInside]; [myButton setTitle:@"I'm fast" forState:UIControlStateNormal]; [myButton setFrame:CGRectMake(20.0, 10.0, 160.0, 30.0)]; [[self myView] addSubview:myButton]; } - (void) initMyTableView { UITableView *newTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,100,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height-100) style:UITableViewStyleGrouped]; self.myTableView = newTableView; self.myTableView.delegate = self; self.myTableView.dataSource = self; } -(void) pressedMyButton { NSLog(@"pressedMyButton"); } - (void)viewDidLoad { [super viewDidLoad]; [[self view] addSubview:self.myView]; [[self view] addSubview:self.myTableView]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CustomCell *customCell = [tableView dequeueReusableCellWithIdentifier:@"CustomCell"]; if (customCell == nil) { customCell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"CustomCell"]; } return customCell; } @end CustomCell.h #import <UIKit/UIKit.h> @interface CustomCell : UITableViewCell @property (retain, nonatomic) UIButton* cellButton; @end CustomCell.m #import "CustomCell.h" @implementation CustomCell @synthesize cellButton; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // button within cell cellButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [cellButton addTarget:self action:@selector(pressedCellButton) forControlEvents:UIControlEventTouchUpInside]; [cellButton setTitle:@"I'm sluggish" forState:UIControlStateNormal]; [cellButton setFrame:CGRectMake(20.0, 10.0, 160.0, 30.0)]; [self addSubview:cellButton]; } return self; } - (void) pressedCellButton { NSLog(@"pressedCellButton"); } @end

    Read the article

  • AVAudioRecorder Memory Leak

    - by Eric Ranschau
    I'm hoping someone out there can back me up on this... I've been working on an application that allows the end user to record a small audio file for later playback and am in the process of testing for memory leaks. I continue to very consistently run into a memory leak when the AVAudioRecorder's "stop" method attempts to close the audio file to which it's been recording. This really seems to be a leak in the framework itself, but if I'm being a bonehead you can tell me. To illustrate, I've worked up a stripped down test app that does nothing but start/stop a recording w/ the press of a button. For the sake of simplicty, everything happens in app. delegate as follows: @synthesize audioRecorder, button; @synthesize window; - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // create compplete path to database NSString *tempPath = NSTemporaryDirectory(); NSString *audioFilePath = [tempPath stringByAppendingString:@"/customStatement.caf"]; // define audio file url NSURL *audioFileURL = [[NSURL alloc] initFileURLWithPath:audioFilePath]; // define audio recorder settings NSDictionary *settings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kAudioFormatAppleIMA4], AVFormatIDKey, [NSNumber numberWithInt:1], AVNumberOfChannelsKey, [NSNumber numberWithInt:AVAudioQualityLow], AVSampleRateConverterAudioQualityKey, [NSNumber numberWithFloat:44100], AVSampleRateKey, [NSNumber numberWithInt:8], AVLinearPCMBitDepthKey, nil ]; // define audio recorder audioRecorder = [[AVAudioRecorder alloc] initWithURL:audioFileURL settings:settings error:nil]; [audioRecorder setDelegate:self]; [audioRecorder setMeteringEnabled:YES]; [audioRecorder prepareToRecord]; // define record button button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(handleTouch_recordButton) forControlEvents:UIControlEventTouchUpInside]; [button setFrame:CGRectMake(110.0, 217.5, 100.0, 45.0)]; [button setTitle:@"Record" forState:UIControlStateNormal]; [button setTitle:@"Stop" forState:UIControlStateSelected]; // configure the main view controller UIViewController *viewController = [[UIViewController alloc] init]; [viewController.view addSubview:button]; // add controllers to window [window addSubview:viewController.view]; [window makeKeyAndVisible]; // release [audioFileURL release]; [settings release]; [viewController release]; return YES; } - (void) handleTouch_recordButton { if ( ![button isSelected] ) { [button setSelected:YES]; [audioRecorder record]; } else { [button setSelected:NO]; [audioRecorder stop]; } } - (void) dealloc { [audioRecorder release]; [button release]; [window release]; [super dealloc]; } The stack trace from Instruments that shows pretty clearly that the "closeFile" method in the AVFoundation code is leaking...something. You can see a screen shot of the Instruments session here: Developer Forums: AVAudioRecorder Memory Leak Any thoughts would be greatly appreciated!

    Read the article

  • UITabBarController + autorotation

    - by ludo
    Hi, I created an application with a TabBarController using IB who have 4 TabBarItems and so display 4 differents ViewControllers. To allow a landscape orientation I must add this code in all of my ViewController: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES); } The problem is I don't want for example the secondViewController to autorotate, How can I do that? Because everytime I delete the code above in one of my ViewController, every ViewControllers not rotate anymore. Thanks

    Read the article

  • iPhone app with tab bar and navigation bar as peers

    - by Mac
    I'm trying to write an application that uses a navigation bar and tab bar in what (I'm gathering) is an unusual manner. Basically, I've got several "pages" ("home", "settings", etc) that each have their own tab. I'd also like to have it so that the "home" page is the root view of the navigation bar, and the other pages are the second-level views of the navigation bar. That is, I should be able to navigate to any page by clicking the appropriate tab bar item, and should be able to navigate to the home page from any other page by clicking the navigation bar's back button. Currently, I have a UINavigationBar (through a UINavigationController) and a UITabBar (through a UITabController) as children of a UIView. The various pages' view controllers are set as the tab controller's viewControllers property, and the home page's controller is also set as the navigation controller's root view. Each page view's tag is set to its index in the tab control. I have the following logic in the tab controller's didSelectViewController delegate method: - (void) tabBarController:(UITabBarController*) tabBarController didSelectViewController:(UIViewController*) viewController { if ([navController.viewControllers count] > 1) [navController popViewControllerAnimated:NO]; [navController pushViewController:viewController animated:YES]; } Also, in the navigation controller's didShowViewController delegate method, I have the following code: - (void) navigationController:(UINavigationController *) navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { tabController.selectedIndex = viewController.view.tag; } The problem that's occurring is that when I run this, the navigation bar, tab bar and home page all display ok, but the tab bar will not respond to input - I cannot select a different tab. I gather it's more usual to have the tab bar as the child of the navigation control, or vice versa. This doesn't seem to fit my approach, because I don't want to have to individually create the subordinate control each time a change occurs in the parent control - eg: recreate tab bar each time the navigation bar changes. Does anyone have suggestions as to what's wrong and how to fix it? I'm probably missing something obvious, but whatever it is I can't seem to find it. Thanks! EDIT: I'm guessing it has something to do with both controller's trying to have ownership of the page controller, but I can't for the life of me figure out a way around it.

    Read the article

  • [objc_getClass("PLCameraController") sharedInstance] always returns nil in iPhone

    - by paul simmons
    I am trying to apply Mike Chen's answer here, using SDK 3.0. In delegate.m file I implement; [viewController.view addSubview:[[objc_getClass("PLCameraController") sharedInstance] previewView]]; and in viewcontroller.m I implement: PLCameraController *cam = [objc_getClass("PLCameraController") sharedInstance]; CapturedImage = [cam _createPreviewImage]; but 'cam' is always nil. Any suggestions?

    Read the article

  • Pop to root SplitViewController in TabBarController - iOS

    - by Mike Bryant
    TableViewController Context: Here's my app: Tab 1: NavigationController -> ViewController Tab 2: SplitViewController -> Master : TableViewController -> SplitViewController ->TableViewController -> Detail : TableViewController -> TableViewController Tab 3: NavigationController -> ViewController (I'm Here) How do I pop to the root of each tab from a method in the tab 3 (basically a logout button)?

    Read the article

  • How do I pass a string or data object between two view controllers?

    - by Jonathan
    In my last question i asked how to best send a string from one view controller to another, both which were on a navigation stack: http://stackoverflow.com/questions/2898860/pass-string-from-tableviewcontroller-to-viewcontroller-in-navigation-stack However I just realised I can either pass the path to the file in the app's document's folder as the first (the table view) has already accessed the data in the file should I pass viewcontroller the data to the pushed VC?

    Read the article

  • Accessing an owners variable

    - by Dyldo42
    Okay, I have a ViewController that has 12 UIButtons as instance variables, and they are created in interface builder. I want to access another variable in the viewController from the UIButton's init method. Is that possible? By the way, I'm writing in Objective-C in the iPhone SDK. Cheers.

    Read the article

  • UILabel not changing when method called

    - by LyonJTill
    - (IBAction)restoreUserDefaults { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if([defaults objectForKey:@"Exam Name"] == nil) { examName = [[NSString alloc] initWithString:@"Name"]; } else { examName = [[NSString alloc] initWithString:[defaults objectForKey:@"Exam Name"]]; } [examNameLabel setText:[NSString stringWithFormat:@"%@",examName]]; } Hey all, Basically above is the method that is being called when one ViewController is being close and another is being opened the problem is, is that the UILabel in the new ViewController isn't changing to the value i need it to? Any ideas? Regards Lyon J Till

    Read the article

  • Problems with creating and using of delegate-protocols

    - by Flocked
    Hello, I have the problem that I have created a delegate protocol, but the necessary methods are not executed, although I have implemented the protocol in my header file. Here are the detailed explanation: I created an instance of my ViewController (TimeLineViewController), which will be displayed. This ViewController contains a UITableView, which in turn receives the individual Cells / Rows from one instance of my TableViewCell. So the ViewController creates an instance of TableCellView. The TableViewCell contains a UITextView, which contains web links. Now I want, that not safari opens the links, but my own built-in browser. Unfortunately TableViewCell can not open a new ViewController with a WebView, so I decided to create a delegate protocol. The whole thing looks like this: WebViewTableCellDelegate.h: @protocol WebViewTableCellDelegate -(void)loadWeb; @end Then I created a instance WebViewDelegate in the TableViewCell: id <WebViewTableCellDelegate> _delegate; In the .m of the TableViewCell: @interface UITextView (Override) @end @class WebView, WebFrame; @protocol WebPolicyDecisionListener; @implementation UITextView (Override) - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener { NSLog(@"request: %@", request); [_delegate loadWeb]; } @end - (void)setDelegate:(id <WebViewTableCellDelegate>)delegate{ _delegate = delegate;} And in my TimeLineViewController I implemented the protocol with < and the loadWeb-metode: - (void)loadWeb{ WebViewController *web = [[WebViewController alloc] initWithNibName:nil bundle:nil]; web.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController: web animated:YES]; [web release]; } And when the instance of the TableViewCell will be created in the TimelineViewController: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; MyIdentifier = @"tableCell"; TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if(cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil]; cell = tableCell;} [cell setDelegate:self]; //… } It is the first time I created a own delegate-protocol, so maybe there are stupid mistakes. Also I´m learnung Objective-C and programming generally only for 4 weeks. Thanks for your help! EDIT: I think i found the problem, but I dont know how to resolve it. I try to use [_delegate loadWeb]; in the subclass of the UITextView (because that is the only way i can react on the weblinks) and the subclass can´t use [_delegate loadWeb];. I tried this in a other methode and it worked.

    Read the article

  • Add subview to another view

    - by Martol1ni
    With two ViewControllers, MyView 1 and MyView 2, is there possible to add a subview to MyView2 from MyView1.m? I have tried: MyView2 * screen = [[MyView2 alloc]initWithNibName:nil bundle:nil]; [screen.view addSubView:mySubView]; But my new instance of MyView 2 has no connection to the 'visible' ViewController on MyView2, right? To clarify, the ViewController that is showing, is MyView1. I want MyView1 to be able to add a subview to the MyView2 view. Thanks

    Read the article

  • Load a list of localized strings at once in IOS

    - by Victor Ronin
    I want to show a table with the list of strings which are localized. The straightforward method would be: a) Point data source to my ViewController b) Define an array c) Allocate the array in my ViewController and init (arrayWithObjects) it with the strings from localized resources (NSLocalizedString) d) Use this array in UITableViewDataSource delegated methods Mainly my concern is item b). The construction looks quite heavy and I wonder whether I can somehow specify and load whole list of localized string at once.

    Read the article

  • How to reference object values from subview?

    - by Frank Martin
    I have a ViewController and add programmatically a subview. During the initialization of the subview (initWithFrame) i want to set some attributes to values according to attributes that belong to another ViewControllers Child-Object (not a view). -(id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // The following is kind of what i want self.myAttribute = [self.viewController.otherObject otherValue]; } return self; } Thanks in advance for any answers and comments how to improve the question. Frank

    Read the article

  • Adding a view with a view controller as a subview of another view controller. Doesn't work.

    - by Tom
    I'm trying to essentially re-implement the UISplitViewController (because it has its limits), but when I create a UIViewController viewController, and then do an "[viewController.view addSubview contentViewController.view]" on it, to add a view that already has a view controller, that content view doesn't seem to get initialised by its view controller. I guess its view controller is getting detached or deallocated, is this the case?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >